python - Why is it important to protect the main loop when using joblib.Parallel? -
the joblib docs contain following warning: under windows, important protect main loop of code avoid recursive spawning of subprocesses when using joblib.parallel. in other words, should writing code this: import .... def function1(...): ... def function2(...): ... ... if __name__ == '__main__': # stuff imports , functions defined ... no code should run outside of “if __name__ == ‘__main__’” blocks, imports , definitions. initially, assumed prevent against occasional odd case function passed joblib.parallel called module recursively, mean practice unnecessary. however, doesn't make sense me why risk on windows. additionally, this answer seems indicate failure protect main loop resulted in code running several times slower otherwise have simple non-recursive problem. out of curiosity, ran super-simple example of embarrassingly parallel loop joblib docs without protecting main loop on windows box. terminal spammed following erro...