GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-123471: Make concurrent iteration over itertools.islice thread-safe using a critical section by eendebakpt · Pull Request #148348 · python/cpython

Conversation

@eendebakpt

@eendebakpt eendebakpt commented Apr 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

In this PR we use a critical section. An alternative approach is to use atomics (#144528), but that is more complex.

  • Issue: Make concurrent iteration over pairwise, combinations, permutations, cwr, product, etc. from itertools safe under free-threading #123471

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@eendebakpt
Make itertools.islice safe in the FT build
0a581a1
@eendebakpt
eendebakpt requested a review from rhettinger as a code owner April 10, 2026 16:52
@bedevere-app bedevere-app Bot added the awaiting review label Apr 10, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Apr 10, 2026
Make concurrent iteration over pairwise, combinations, permutations, cwr, product, etc. from itertools safe under free-threading #123471
Open
@eendebakpt eendebakpt mentioned this pull request Apr 10, 2026
gh-123471: Make concurrent iteration over itertools.islice thread-safe #144528
Closed
@eendebakpt
news entry
5ee09e1
@eendebakpt eendebakpt added the topic-free-threading label Apr 10, 2026
@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 18, 2026
@eendebakpt
Merge branch 'main' into islice_ft_cs
1024151
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label May 26, 2026
@eendebakpt eendebakpt mentioned this pull request Jun 12, 2026
gh-151409: add critical section for islice_next #151410
Closed
@dpdani

dpdani commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

I could not reproduce the new test against main. I reproduced an assertion failure after changing the numbers.

    @threading_helper.reap_threads
    def test_islice(self):
        number_of_iterations = 600
        for _ in range(number_of_iterations):
            it = islice(tuple(range(100000)), 1, 8000000, 2)
            threading_helper.run_concurrently(work_iterator, nthreads=10, args=[it])

Which resulted in:

Python/gc_free_threading.c:1083: validate_refcounts: Assertion "_Py_REFCNT(((PyObject*)((op)))) > 0" failed: tracked objects must have a reference count > 0

I didn't check how long it takes to run this test, but we would ideally keep it short. Can you find a way to make it reliably fail on main?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ambv ambv mentioned this pull request Oct 20, 2026
gh-123471: Make concurrent iteration over itertools.pairwise thread-safe #144489
Open
@github-actions

github-actions Bot commented Oct 27, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rhettinger rhettinger Awaiting requested review from rhettinger rhettinger is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review stale Stale PR or inactive for long period of time. topic-free-threading

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@eendebakpt @dpdani
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.