The following example works, but it leads to an ugly error message when the main process exits:
import pathos
with pathos.pools.ProcessPool(4) as pool:
...
Output
Exception ignored in: <function Pool.__del__ at 0x7f8c7e23d160>
Traceback (most recent call last):
File "/home/me/some_venv/lib/python3.8/site-packages/multiprocess/pool.py", line 268, in __del__
File "/home/me/some_venv/lib/python3.8/site-packages/multiprocess/queues.py", line 365, in put
File "/home/me/some_venv/lib/python3.8/site-packages/multiprocess/reduction.py", line 54, in dumps
File "/home/me/some_venv/lib/python3.8/site-packages/multiprocess/reduction.py", line 42, in __init__
File "/home/me/some_venv/lib/python3.8/site-packages/dill/_dill.py", line 573, in __init__
ImportError: sys.meta_path is None, Python is likely shutting down
The process return code is 0 though, i.e., it isn't a "real" error/crash.
The involved libraries should be relatively up-to-date.
pathos==0.2.9
dill==0.3.5.1