python / python/cpython

multiprocessing async .get() hangs if the pool is terminated

Open
#126,743 3 comments 0 reactions 0 assignees View on GitHub

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 outside with 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.