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

Created on 2018-12-13 00:30 by vstinner, last changed 2018-12-14 10:12 by vstinner.

Pull Requests
URL Status Linked Edit
PR 11136 closed vstinner, 2018-12-13 00:53
PR 11139 open vstinner, 2018-12-13 02:28
Messages (2)
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.
History
Date User Action Args
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