This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients emptysquare, ionelmc, ronaldoussoren, serhiy.storchaka, terry.reedy, vstinner, yselivanov
Date 2020-05-14.23:42:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> 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".
Date User Action Args
2020-05-14 23:42:29vstinnersetrecipients: + vstinner, terry.reedy, ronaldoussoren, ionelmc, serhiy.storchaka, yselivanov, emptysquare
2020-05-14 23:42:29vstinnersetmessageid: <>
2020-05-14 23:42:29vstinnerlinkissue25920 messages
2020-05-14 23:42:29vstinnercreate