FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-123471: Make concurrent iteration over itertools.islice thread-safe using a critical section by eendebakpt · Pull Request #148348 · python/cpython · GitHub

/ cpython Public

gh-123471: Make concurrent iteration over itertools.islice thread-safe using a critical section - #148348

Open
eendebakpt wants to merge 3 commits into
python:mainfrom
eendebakpt:islice_ft_cs
Open

gh-123471: Make concurrent iteration over itertools.islice thread-safe using a critical section#148348
eendebakpt wants to merge 3 commits into
python:mainfrom
eendebakpt:islice_ft_cs

Conversation

eendebakpt commented Apr 10, 2026
edited
Loading

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.

Copy link
Copy Markdown

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

github-actions Bot added the stale Stale PR or inactive for long period of time. label May 18, 2026
github-actions Bot removed the stale Stale PR or inactive for long period of time. label May 26, 2026

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?

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL