Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed
Labels
topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Sequence iterators are not thread-safe under the free-threaded build. They'll sometimes be accessed with the same index.
Here is a minimal repro:
importconcurrent.futuresN=10000for_inrange(100): it=iter(range(N)) withconcurrent.futures.ThreadPoolExecutor() asexecutor: data=set(executor.map(lambda_: next(it), range(N))) assertlen(data) ==N, f"Expected {N} distinct elements, got {len(data)}"I also tested it with list and dict iterators as well as a custom class implementing __getitem__.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux, macOS
Linked PRs
Metadata
Metadata
Assignees
Labels
topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error