[issue42969] pthread_exit & PyThread_exit_thread from PyEval_RestoreThread etc. are harmful

STINNER Victor report at bugs.python.org
Fri Sep 24 07:20:42 EDT 2021


STINNER Victor <vstinner at python.org> added the comment:

> In this case that unexpected thread simply disappearing can lead to a deadlock in our process.

This problem also remains me the very complex case of bpo-6721: "Locks in the standard library should be sanitized on fork". The issue title looks simple, but 12 years after the issue was created, it's still open.

This issue is being solved by adding atfork callbacks to modules which must do something at fork in the child process (sometimes also in the parent process).

I added threading.Lock._at_fork_reinit() private method to simplify the implementation of these callbacks.

Such problem has no silver bullet solution, so it's better to let developers design their own solution with their specific requirements.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42969>
_______________________________________


More information about the Python-bugs-list mailing list