This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mutax
Recipients docs@python, mutax
Date 2021-07-12.22:18:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1626128316.93.0.838560232198.issue44615@roundup.psfhosted.org>
In-reply-to
Content
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()
History
Date User Action Args
2021-07-12 22:18:36mutaxsetrecipients: + mutax, docs@python
2021-07-12 22:18:36mutaxsetmessageid: <1626128316.93.0.838560232198.issue44615@roundup.psfhosted.org>
2021-07-12 22:18:36mutaxlinkissue44615 messages
2021-07-12 22:18:36mutaxcreate