[issue18966] Threads within multiprocessing Process terminate early

Eryk Sun report at bugs.python.org
Thu Jul 14 11:58:12 EDT 2016


Eryk Sun added the comment:

> all atexit handlers, for example, would be called multiple times.

Davin is (I think) proposing a multiprocessing atexit facility, which can be used to ensure threading._shutdown is called. But could Python's regular atexit handling be reset in the child, allowing Py_Finalize to be called? In other words, can atexit can be integrated into the PyOS_AfterFork (Modules/signalmodule.c) sequence? multiprocessing could set a sys flag that forces atexit to clear its registered handlers, and for Py_AtExit, reset the static nexitfuncs variable in Python/pylifecycle.c. Or is that just opening a can of worms that will cause Py_Finalize to crash in various scenarios?

> There's also the problem that fork() isn't MT-safe

This issue is about joining Python threads created in the child, which has a clean slate via PyOS_AfterFork, PyEval_ReInitThreads (Python/ceval.c), and threading._after_fork.

----------

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


More information about the Python-bugs-list mailing list