multiprocessing async .get() hangs if the pool is terminated
Open
Nobody has claimed this yet.
stdlib
topic-multiprocessing
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
MWE
Steps to reproduce:
import multiprocessing
from time import sleep
with multiprocessing.Pool() as p:
result = p.apply_async(sleep, (1,))
result.get()
Expected behavior:
Either:
- result is returned. (
Pool().__exit__waits for every async task to finish); or - some kind of exception is raised when
.get()is called outsidewith Pool()
Comments
This is the same as #79659. That was marked as completed in 2021. However it seems the issue is still present.
CPython versions tested on:
3.12, 3.13, 3.14
Operating systems tested on:
Linux
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided MWE and tracing the interaction between Pool.exit and the asynchronous result's .get() call after the pool is terminated. Compare the behavior with issue #79659 and add coverage for the documented expected outcome: completion or an exception instead of a hang.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100