-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-multiprocessingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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):
- fetch the next
argfrominterableand put a task forfn(arg)in the buffer - wait for next result to be available
- 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
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-multiprocessingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error