Concurrency Tips & Tricks
Use with statement to manage locks
Starting in Python 2.5, the with statement is a far easier way to manage locks:
Toggle line numbers
1 some_lock = threading.Lock()
2
3 with some_lock:
4 do_stuff_requiring_lock()
This is equivalent to: