Python Lock / Mutex minimal example (threading.Lock)
This minimal example creates a threading.Lock
and locks it using a with
statement. This is the simplest way of using a Lock
.
from threading import Lock
lock = Lock()
with lock:
print("Holding the lock!")
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow