PyDocs

Nav

Concurrent Execution

Lock

threading

classnot WASI
A lock object is a synchronization primitive.  To create a lock,
call threading.Lock().  Methods are:

acquire() -- lock the lock, possibly blocking until it can be obtained
release() -- unlock of the lock
locked() -- test whether the lock is currently locked

A lock is not owned by the thread that locked it; another thread may
unlock it.  A thread attempting to lock a lock that it has already locked
will block until another thread unlocks it.  Deadlocks may ensue.
Changed in 3.13
  • 3.13: Lock is now a class. In earlier Pythons, Lock was a factory function which returned an instance of the underlying private lock type.
Members of Lock

a

acquire
Lock the lock.

l

locked
Return whether the lock is in the locked state.

r

release
Release the lock.
0 Examples
No examples for threading/Lock.
See Also
No see-alsos for threading/Lock
0 Notes
No notes for Lock