Skip to content

bpo-32186: Release the GIL during lseek and fstat#4652

Merged
vstinner merged 3 commits into
python:masterfrom
nirs:fileio-gil-master
Dec 1, 2017
Merged

bpo-32186: Release the GIL during lseek and fstat#4652
vstinner merged 3 commits into
python:masterfrom
nirs:fileio-gil-master

Conversation

@nirs

@nirs nirs commented Nov 30, 2017

Copy link
Copy Markdown
Contributor

In _io_FileIO_readall_impl, lseek and _Py_fstat_noraise were called
without releasing the GIL. This can cause all threads to hang for
unlimited time when calling FileIO.read() and the NFS server is not
accessible.

https://bugs.python.org/issue32186

@nirs

nirs commented Nov 30, 2017

Copy link
Copy Markdown
Contributor Author

@vstinner can you review?

In _io_FileIO_readall_impl, lseek and _Py_fstat_noraise were called
without releasing the GIL. This can cause all threads to hang for
unlimited time when calling FileIO.read() and the NFS server is not
accessible.
@nirs nirs force-pushed the fileio-gil-master branch from c2d6dfd to 1258ef4 Compare November 30, 2017 18:29
@nirs nirs changed the title bpo-XXX: Release the GIL during lseek and fstat bpo-32186: Release the GIL during lseek and fstat Nov 30, 2017

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code change LGTM, but I'm unhappy with the NEWS entry.

@@ -0,0 +1,3 @@
Fixed hang of all threads when using io.FileIO with inaccessible NFS server.
Now only the thread accessing the problematic storage will hang. Patch by

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"io.FileIO" is unclear. IMHO it's better here to mention the impacted methods, so read and readall, and mention the GIL. I propose:

io.FileIO.readall() and io.FileIO.read() now releases the GIL when getting the file size. Fixed hang of all threads with inaccessible NFS server. Patch by Nir Soffer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with your suggestion, updating 👍

- Mention the impacted methods and the GIL (Victor)
@nirs nirs force-pushed the fileio-gil-master branch from cfebbec to 4da8169 Compare November 30, 2017 22:46

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @nirs for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-4661 is a backport of this pull request to the 3.6 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 1, 2017
In _io_FileIO_readall_impl(), lseek() and _Py_fstat_noraise() were called
without releasing the GIL. This can cause all threads to hang for
unlimited time when calling FileIO.read() and the NFS server is not
accessible.
(cherry picked from commit 6a89481)
vstinner pushed a commit that referenced this pull request Dec 1, 2017
In _io_FileIO_readall_impl(), lseek() and _Py_fstat_noraise() were called
without releasing the GIL. This can cause all threads to hang for
unlimited time when calling FileIO.read() and the NFS server is not
accessible.
(cherry picked from commit 6a89481)
@nirs nirs deleted the fileio-gil-master branch October 1, 2022 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants