-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Open
Labels
Description
Feature or enhancement
Python doesn't currently have a thread-safe atomic counter. CPython currently internally uses a few different patterns to implement thread-safe counters. For example, some test code uses appends to a shared list because the implementation of list.append() is atomic.
We should provide a counter that is explicitly thread-safe so that people don't have to rely on other idioms. The minimum initial API should provide:
- atomic increment
- get value (i.e., inspect)
The threading module may be a good place for it.
cc @rhettinger
Eclips4, zware, ZeroIntensity and kumaraditya303