MCPcopy Create free account
hub / github.com/dabeaz/python-cookbook / incr

Method incr

src/12/how_to_lock_critical_sections/example1.py:11–16  ·  view source on GitHub ↗

Increment the counter with locking

(self,delta=1)

Source from the content-addressed store, hash-verified

9 self._value_lock = threading.Lock()
10
11 def incr(self,delta=1):
12 '''
13 Increment the counter with locking
14 '''
15 with self._value_lock:
16 self._value += delta
17
18 def decr(self,delta=1):
19 '''

Callers 1

testFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected