[issue43145] Leak of locks from multiprocessing.Process

Boris Staletic report at bugs.python.org
Wed Feb 10 06:20:06 EST 2021


Boris Staletic <boris.staletic at gmail.com> added the comment:

The `multiprocessing.Process`, on Linux, ends up doing something like this:

pid = os.fork()
if pid == 0: os._exit()

Translated to C:

int main() {
    Py_Initialize();
    PyOS_BeforeFork();
    pid_t pid = fork();
    if (pid == 0) {
        PyOS_AfterFork_Child(); // Reinitializes stuff.
        _exit(0); // Child process exits without cleanup.
    }
    PyOS_AfterFork_Parent();
    Py_Finalize();
}

The call to `_exit()` happens in Lib/multiprocessing/popen_fork.py#L73

My attempts at cleaning this up resulted in even more problems.

----------

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


More information about the Python-bugs-list mailing list