import threadinglock = threading.Lock()lock.acquire()try: #do somethingfinally: lock.relase()
import threadinglock = threading.Lock()with lock: #do something