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-124397: Add pure Python implementation of `threading.iter_locked` by eendebakpt · Pull Request #138261 · python/cpython

Conversation

@eendebakpt

@eendebakpt eendebakpt commented Aug 30, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Add a Python implementation of iter_locked.

Continuation of #133908 and #133272. The name was discussed in discuss.python.org

Since this is now a pure python implementation, we could also consider adding this to packages such as https://github.com/facebookincubator/ft_utils or https://github.com/dpdani/cereggii

  • Issue: Strategy for Iterators in Free Threading #124397

📚 Documentation preview 📚: https://cpython-previews--138261.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

All reactions
eendebakpt and others added 14 commits May 10, 2025 23:23
@eendebakpt
Add iter_locked
6313b3d
@eendebakpt
cleanup
5ced0a9
@eendebakpt
cleanup
110332e
@blurb-it
📜🤖 Added by blurb_it.
b675631
@eendebakpt
update docs
4406050
@eendebakpt
review comments
d30ace8
@eendebakpt
use explicit lock
baec5bc
@eendebakpt
Merge branch 'main' into iter_locked
e6ea285
@eendebakpt
fix import
7315c49
@eendebakpt
cleanup after merge to main
b7c9d77
@eendebakpt
reduce duration of test
bb98c52
@eendebakpt
use recursive lock
946ee51
@eendebakpt
Merge branch 'main' into iter_locked
7e3653a
@eendebakpt
add python implementation
d314fe0
@bedevere-app bedevere-app Bot added the awaiting review label Aug 30, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Aug 30, 2025
Strategy for Iterators in Free Threading #124397
Open
eendebakpt added 2 commits August 30, 2025 12:04
@eendebakpt
cleanup
ca83c7e
@eendebakpt
cleanup
b2811e4
@picnixz

picnixz commented Aug 30, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

I would have really preferred something like threading.iterate to mimick the way we name things, e.g., enumerate[this], iter[over that], filter[this], map[it], etc (all of them are verbs), but I see why it's named iter_locked to mimick iter, though it looks like a variable name to me rather than a function name. My rationale for not having locked inside the name is that it belongs to the threading module, and thus semantically should be used by something that is threading-related, but this is probably too many guesses

All reactions

Sorry, something went wrong.

Uh oh!

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

@picnixz picnixz changed the title gh-124397: Add threading.iter_locked gh-124397: Add pure Python implementation of threading.iter_locked Aug 30, 2025
@ZeroIntensity

ZeroIntensity commented Aug 30, 2025

Copy link
Copy Markdown
Member

I'm still not a huge fan of putting this in threading. threading should be for synchronization primitives, but this is a utility.

All reactions

Sorry, something went wrong.

Uh oh!

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

@eendebakpt

eendebakpt commented Aug 30, 2025

Copy link
Copy Markdown
Contributor Author

Just an idea: what about using the builtin iter with a new keyword locked? For locked=False we have the normal behavior, for True we use the iter_locked defined here.

All reactions

Sorry, something went wrong.

Uh oh!

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

@ZeroIntensity

ZeroIntensity commented Aug 30, 2025

Copy link
Copy Markdown
Member

I like that idea, but it would require a lot more work to accomplish. Changes to builtins require PEPs.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions

github-actions Bot commented Apr 28, 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 Apr 28, 2026
@eendebakpt

eendebakpt commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

#148894 is a more complete implementation, closing this PR

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Apr 29, 2026

Copy link
Copy Markdown
Member

#148894 is a more complete implementation, closing this PR

You didn't close the PR. I suppose that it was a mistake, so I close the PR.

eendebakpt reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner closed this Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

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.

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.

4 participants

@eendebakpt @picnixz @ZeroIntensity @vstinner
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 01402503 — 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.