3 ms·
Define the function you're passing to the pool before you create the pool, and make sure you use an 'if __name__ == "__main__: main()" line at the end if you're
by andreasvc 13y ago
Define the function you're passing to the pool before you create the pool, and make sure you use an 'if __name__ == "__main__: main()" line at the end if you're writing a script, since it needs to be importable.
If functions within functions are not supported I don't see the problem, because the thing with multiprocessing is that you need to be conscious of what you're passing between processes, so explicitly passing everything as arguments or through an initializer is the way to go.