MCPcopy Index your code
hub / github.com/bslatkin/effectivepython / LockingGrid

Class LockingGrid

example_code/item_073.py:298–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296from threading import Lock
297
298class LockingGrid(Grid):
299 def __init__(self, height, width):
300 super().__init__(height, width)
301 self.lock = Lock()
302
303 def __str__(self):
304 with self.lock:
305 return super().__str__()
306
307 def get(self, y, x):
308 with self.lock:
309 return super().get(y, x)
310
311 def set(self, y, x, state):
312 with self.lock:
313 return super().set(y, x, state)
314
315
316print("Example 8")

Callers 2

simulate_phased_pipelineFunction · 0.70
item_073.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected