I'm created a dedicated environment for my new project using anacoda on Windows 10. I write and run my code from Jupyter Notebook where I want to use multiprocessing
but after I run even the most straightforward code from the module's documentation it gets stuck. Here's the code:
from multiprocessing import Pool
def f(x):
return x*x
if __name__ == '__main__':
with Pool(5) as p:
print(p.map(f, [1, 2, 3]))
Code below also doesn't work:
p = Pool(5)
results = p.map(f, [1, 2, 3])
print(results)
Changing the environment to the base doesn't help. However, while running the code from PyCharm it works perfectly fine. Also it runs fine in Jupyter on Linux. I assume then it must be something Windows-Jupyter-related.
Versions of libraries I use:
python = 3.10.4
jupyter = 1.0.0
CPU: Intel i5 (but it shouldn't matter I think).
I've found a topic related to the same topic: Python multiprocessing on Windows 10
It's mentioned there, that it was an issue when using multiprocessing through venv but it is solved since Python 3.7.3.
Any ideas on how to solve the issue? Any workarounds?