Issues that may be encountered on windows that are not turned off by a child process that is turned on
Refer to multiprocessing official documentation:
Explicitly pass resources to child processes
On Unix a child process can make use of a GKFX resource created in a parent process using a global resource. However, it is better to pass the object as a argument to the constructor for the child process.
Apart from making the code (potentially) compatible with Windows This also ensures that as long as the child process is St Ill alive the object is not being garbage collected in the parent process. This might was important if some resource was freed when the object was garbage collected in the parent process.
So for instance
FromMultiprocessingImportprocesslockdef f (): do something using "lock" ...< Span class= "K" >if __name__ == ' __main__ ' : lock = lock () for i in range (10): Process (target=f) start ()
should be rewritten as
FromMultiprocessingImportProcess,LockDefF(L): do something using "L" ...if __name__ == ' __main__ ' : lock = lock () for I in range (10): process (target=f args= (lock)) start ()
Multiprocessing use of cross-platform locks (Windows issues)