Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

concurrent.futures.Executor.map temporarily exceeds its buffersize while collecting the next result #131466

Open
ebonnal opened this issue Mar 19, 2025 · 1 comment
Labels
stdlib Python modules in the Lib dir topic-multiprocessing type-bug An unexpected behavior, bug, or error

Comments

@ebonnal
Copy link
Contributor

ebonnal commented Mar 19, 2025

Bug report

Bug description:

Potential follow up after the merge of #125663 (introduce buffersize param in Executor.map).

"Bug": concurrent.futures.Executor.map temporarily exceeds its buffersize while collecting the next result:

Let's define:

results: Iterator = executor.map(fn, iterable, buffersize=buffersize)

What happens when calling next(results):

  1. fetch the next arg from interable and put a task for fn(arg) in the buffer
  2. wait for next result to be available
  3. yield the collected result

So during step 2. the buffer's size is actually buffersize + 1.

If we want a strict guarantee that there is at most buffersize concurrent tasks even during a next, we have to swap step 1. and step 2.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

@ebonnal ebonnal added the type-bug An unexpected behavior, bug, or error label Mar 19, 2025
@ebonnal ebonnal changed the title concurrent.futures.Executor.map temporarily exceeds its buffersize while collecting the next result. concurrent.futures.Executor.map temporarily exceeds its buffersize while collecting the next result Mar 19, 2025
@picnixz picnixz added stdlib Python modules in the Lib dir topic-multiprocessing labels Mar 22, 2025
@picnixz
Copy link
Member

picnixz commented Mar 22, 2025

(Ok it's not really multiprocessing topic but it's close to)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-multiprocessing type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants