[issue36533] logging regression with threading + fork are mixed in 3.7.1rc2 (deadlock potential)
Gregory P. Smith
report at bugs.python.org
Fri Apr 5 05:02:35 EDT 2019
Gregory P. Smith <greg at krypto.org> added the comment:
Now to back up: Why was this application using fork() in a threaded application at all? That is a fundamental flaw. Should we be doing work to support things that so far merely _happen_ to work on such broken designs?
Another alternative for the DebugHandler implementation in whatever code implemented it is for it to de-register itself from the logging library's private WeakSet of handler locks to acquire at fork time from its own constructor. We don't have a public API for this so the workaround doing that on 3.7.1 - 3.7.3 would look like:
def __init__(self, ...):
super().__init__(...)
if hasattr(logging, '_at_fork_acquire_release_weakset'):
logging._at_fork_acquire_release_weakset.discard(self)
This means it'd still have the bug the code already had on all prior to versions of Python before this logging library "acquire the locks before fork" fix went in: Namely if the forked child tries to log it could deadlock due to forking while the inherited logging handler lock held.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36533>
_______________________________________
More information about the Python-bugs-list
mailing list