PyDocs

Nav

Concurrent Execution

Lock.acquire

threading

method of Locknot WASI
  • Lock.acquire(blocking=True, timeout=-1)
Lock the lock.

Without argument, this blocks if the lock is already locked
(even by the same thread), waiting for another thread to release
the lock, and return True once the lock is acquired.
With an argument, this will only block if the argument is true,
and the return value reflects whether the lock is acquired.
The blocking operation is interruptible.
Changed in 3.2, 3.14, 3.15
  • 3.2: The timeout parameter is new.
  • 3.2: Lock acquisition can now be interrupted by signals on POSIX if the underlying threading implementation supports it.
  • 3.14: Lock acquisition can now be interrupted by signals on Windows.
  • 3.15: Accepts any real number as timeout, not only integer or float.
0 Examples
No examples for threading/Lock.acquire.
See Also
No see-alsos for threading/Lock.acquire
0 Notes
No notes for Lock.acquire