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
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:
I also tested it with
listanddictiterators as well as a custom class implementing__getitem__.CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux, macOS
Linked PRs