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.

classification
Title: multiprocessing: ApplyResult.get() hangs if the pool is terminated
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: davin, pablogsal, pitrou, vstinner
Priority: normal Keywords: patch

Created on 2018-12-13 00:30 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11136 closed vstinner, 2018-12-13 00:53
PR 11139 closed vstinner, 2018-12-13 02:28
Messages (3)
msg331724 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-12-13 00:30
The following code hangs:
---
import multiprocessing, time
pool = multiprocessing.Pool(1)
result = pool.apply_async(time.sleep, (1.0,))
pool.terminate()
result.get()
---

pool.terminate() terminates workers before time.sleep(1.0) completes, but the pool doesn't mark result as completed with an error.

Would it be possible to mark all pending tasks as failed? For example, "raise" a RuntimeError("pool terminated before task completed").
msg331793 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-12-14 10:12
Attached PR 11139 sets RuntimeError("Pool terminated") error in pending results if the pool is terminated.
msg336940 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-03-01 17:28
Pablo: since you worked on multiprocessing recently, did you see this bug? I'm not sure about my PR 11139...

If someone else wants to work on a fix, ignore my PR ;-)
History
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79659
2021-09-21 22:26:36vstinnersetstatus: open -> closed
resolution: out of date
stage: patch review -> resolved
2021-09-21 22:26:17vstinnerunlinkissue35479 dependencies
2019-03-01 17:28:19vstinnersetnosy: + pitrou, davin
messages: + msg336940
2018-12-14 11:56:25vstinnerlinkissue35479 dependencies
2018-12-14 10:12:35vstinnersetmessages: + msg331793
2018-12-13 02:28:44vstinnersetpull_requests: + pull_request10370
2018-12-13 00:53:48vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request10369
2018-12-13 00:30:51vstinnercreate