I'm facing an issue with concurrent.futures's ProcessPoolExecutor, which I'm trying to use in of my classes:
def __init__():
self._pool = ProcessPoolExecutor()
def handle_event():
...
filepath: Path = xxxx
future = self._pool.submit(self.test, filepath)
res = future.result()
self.logger.debug(res)
def test(self, filepath: Path):
print("Test ProcessPoolExecutor")
return 3
This little code has a strange behavior.
First, when I remove getting the result with future.result(), I see no output of my print message in the test() function.
Then, when I explicitely ask for the result of the future, I'm getting a TypeError:
Traceback (most recent call last):
File "/usr/lib/python3.8/multiprocessing/queues.py", line 239, in _feed
obj = _ForkingPickler.dumps(obj)
File "/usr/lib/python3.8/multiprocessing/reduction.py", line 51, in dumps
cls(buf, protocol).dump(obj)
TypeError: cannot pickle 'PyCapsule' object
What I don't understand here is that the types I'm sending (
Path) and receiving (int) are both Picklable.Secondly, I don't even know what this PyCapsule dependency is, since it doesn't appear in my
requirements.txt, nor inpip freeze(related SO post)
.nox/run/bin/pip freeze | grep -E '(capsule|dill)'
Any idea why I cannot see my print statements appearing ? What about the PyCapsule errors ? Is it an issue with my types, or somewhere else in the application ?
Thanks !