[issue7736] os.listdir hangs since opendir() and closedir() do not release GIL

Antoine Pitrou report at bugs.python.org
Wed Jan 20 13:19:19 CET 2010


Antoine Pitrou <pitrou at free.fr> added the comment:

Ah, thanks for the explanation. Yes indeed the patch looks ok for the
job. You should just be aware that similar problems may appear with
other system calls. I don't think we have ever considered that common C
calls such as opendir() could call back into Python code through
libraries such as FUSE.

By the way, it seems there are Python bindings for FUSE, in two
different flavours. You might want to look into them, and perhaps to
check whether they also experience this issue.

Le mercredi 20 janvier 2010 à 12:12 +0000, Nikolaus Rath a écrit :
> Nikolaus Rath <Nikolaus at rath.org> added the comment:
> 
> In this simple example, FUSE does not fork and does not start any threads.
> 
> Note that PyGILState_Ensure() cannot do anything here. What happens is this:
> 
>  - call_hello.py calls FUSE in a new thread, releasing the GIL.
>  - FUSE mounts the file system and waits for requests
>  - Meanwhile, in the main thread, call_hello.py calls opendir(), but does not release the GIL
>  - FUSE receives the opendir() system call and calls the appropriate callback function
>  - If the callback function is implemented in C, everything works fine.
>  - If the callback function is implemented in Python, the FUSE thread tries to acquire the GIL to call the (Python) opendir() handler. But it cannot do so, because the GIL is still held by the main thread (which is waiting for the opendir syscall to return) => deadlock.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7736>
_______________________________________


More information about the Python-bugs-list mailing list