Message397360
The docs at the url
https://docs.python.org/3/library/multiprocessing.html#module-multiprocessing.pool
state in a red warning box:
"Warning
multiprocessing.pool objects have internal resources that need to be properly managed (like any other resource) by using the pool as a context manager or by calling close() and terminate() manually. Failure to do this can lead to the process hanging on finalization."
however, when using the context manager, as it is also shown in the examples, the context manager will call terminate() instead of close() and join() on the pool, possible leading to deadlocks if I understand the documentation correct.
It seems the only safe way of using a Pool as Context Manager is to manually call pool.close() and pool.join() prior to leaving it, which, to be honest, does not make sense to me.
see pool.py:
def __exit__(self, exc_type, exc_val, exc_tb):
self.terminate() |
|
Date |
User |
Action |
Args |
2021-07-12 22:18:36 | mutax | set | recipients:
+ mutax, docs@python |
2021-07-12 22:18:36 | mutax | set | messageid: <1626128316.93.0.838560232198.issue44615@roundup.psfhosted.org> |
2021-07-12 22:18:36 | mutax | link | issue44615 messages |
2021-07-12 22:18:36 | mutax | create | |
|