Message368881
> 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:29 | vstinner | set | recipients:
+ vstinner, terry.reedy, ronaldoussoren, ionelmc, serhiy.storchaka, yselivanov, emptysquare |
2020-05-14 23:42:29 | vstinner | set | messageid: <1589499749.93.0.372285101362.issue25920@roundup.psfhosted.org> |
2020-05-14 23:42:29 | vstinner | link | issue25920 messages |
2020-05-14 23:42:29 | vstinner | create | |
|