Skip to content

Add AtomicCounter class to threading module #129183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

haim0n
Copy link

@haim0n haim0n commented Jan 22, 2025

  • Implemented AtomicCounter class for thread-safe increment and decrement operations.
  • Ensured thread safety using a Lock.

@ghost
Copy link

ghost commented Jan 22, 2025

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jan 22, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to get discussed on DPO first. I'm not convinced that we need this.

@tomasr8
Copy link
Member

tomasr8 commented Jan 22, 2025

Related issue: #124366

@ZeroIntensity
Copy link
Member

That looks promising. I think there's more to this, though, and we should still probably go to DPO (but maybe an issue is fine).

A number of things that should still get discussed:

  • What should we call these methods? (inc and dec are definitely subject to bikeshedding.)
  • We should take a look at prior work in cereggii, which tests these kinds of things on PyPI.
  • Do we want a C accelerator in the _thread module?
  • On top of that, there was some inclination in that issue to add things like this to the C API.

- Implemented AtomicCounter class for thread-safe increment and decrement operations.
- Ensured thread safety using a Lock.
@bedevere-app
Copy link

bedevere-app bot commented Jan 22, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

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.

3 participants