[issue874900] threading module can deadlock after fork

Antoine Pitrou report at bugs.python.org
Fri Jan 25 22:59:05 CET 2008


Antoine Pitrou added the comment:

It's not only the _active_limbo_lock. All global structures of the
threading module should be reinitialized (including the _MainThread
instance); for that purpose, reload() can be used. I attach an example
which exercises this problem. Normally the script should hang in the
last step (using os.fork() and launching threads while some other
threads call threading.enumerate() in a loop).

The safe_fork() function in the example is a replacement for os.fork()
which tries to avoid any deadlock in the threading module. If it's
deemed useful and bug-free, it could perhaps be added somewhere in the
stdlib (in the threading module itself perhaps).

----------
nosy: +pitrou
Added file: http://bugs.python.org/file9288/fork_threading.py

____________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue874900>
____________________________________


More information about the Python-bugs-list mailing list