I believe that on Windows, since there is no plug, the multiprocessing module reloads the modules in new Python processes.
You must have this code in your main script, otherwise very nasty crashes
if __name__ == '__main__': from multiprocessing import freeze_support freeze_support()
I have a bunch of modules that have debug print statements in them at the module level. Therefore, print statements are invoked whenever a module is loaded.
Whenever I run something in parallel, all these print statements are executed.
My question is, is there a way to see if a module is being imported by a multiprocessing module, and if so it disables these print statements?
I basically look to see if there is something like:
import multiprocessing if not multiprocessing.in_parallel_process: print('Loaded module: ' + __name___)
I could not find it so far. Is it possible?
source share