Post-processing Results After Multi-processing In Python
Solution 1:
As @Ares already implied, you fix the problem by indenting everything south the if __name__ == "__main__"
-statement into the if-block.
FYI, this happens on Windows which doesn't provide forking for starting up new processes like Unix-y systems, but uses 'spawn' as default (and only) start-method. Spawn means, the OS has to boot a new process with an interpreter from scratch for every worker-process.
Your worker-processes will need to import your target function my_function
. When this happens, everything not protected within the if __name__ == "__main__":
-block will also run in every child-process on import.
Solution 2:
Your problem is that when you run np.concatenate
, it's not done in the main function. I suspect that the problem you're encountering is Spyder specific, but updating the indentation should fix it.
Post a Comment for "Post-processing Results After Multi-processing In Python"