Execute in a multiprocessing child dynamic code loaded by the parent process

Martin Di Paola martinp.dipaola at gmail.com
Sun Mar 6 15:42:28 EST 2022


>Try to use `fork` as "start method" (instead of "spawn").

Yes but no. Indeed with `fork` there is no need to pickle anything. In
particular the child process will be a copy of the parent so it will
have all the modules loaded, including the dynamic ones. Perfect.

The problem is that `fork` is the default only in Linux. It works in
MacOS but it may lead to crashes if the parent process is multithreaded
(and the my is!) and `fork` does not work in Windows.


More information about the Python-list mailing list