STINNER Victor <vstin...@python.org> added the comment:

> Maybe instead of releasing the lock in the forked child process, we should 
> try to acquire the lock in the os.fork() implementation, and then release it?

In bpo-40089, I added _PyThread_at_fork_reinit() for this purpose: reinitialize 
a lock after a fork to unlocked state. Internally, it leaks memory on purpose 
and then create a new lock, since there is no portable way to reset a lock 
after fork.

The problem is how to register netdb_lock of Modules/socketmodule.c into a list 
of locks which should be reinitialized at fork, or maybe how to register a C 
callback called at fork. There is a *Python* API to register a callback after a 
fork: os.register_at_fork().

See also the meta-issue bpo-6721: "Locks in the standard library should be 
sanitized on fork".

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue25920>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to