qudi.util.mutex.RecursiveMutex

class qudi.util.mutex.RecursiveMutex[source]

Bases: qudi.util.mutex.Mutex

Extends QRecursiveMutex which serves as access serialization between threads.

This class provides: * Drop-in replacement for threading.Lock * Context management (enter/exit)

NOTE: A recursive mutex is much more expensive than using a regular mutex. So consider refactoring your code to use a simple mutex before using this object.

__init__()[source]

Methods

__init__()

acquire([blocking, timeout])

Mimics threading.Lock.acquire() to allow this class as a drop-in replacement.

isRecursive(self)

lock(self)

release()

Mimics threading.Lock.release() to allow this class as a drop-in replacement.

tryLock(-> bool)

try_lock(self)

unlock(self)

Attributes

NonRecursive

Recursive

NonRecursive = PySide2.QtCore.QMutex.RecursionMode.NonRecursive
class RecursionMode

Bases: builtins.object

NonRecursive = PySide2.QtCore.QMutex.RecursionMode.NonRecursive
Recursive = PySide2.QtCore.QMutex.RecursionMode.Recursive
name

!! processed by numpydoc !!

values = {'NonRecursive': PySide2.QtCore.QMutex.RecursionMode.NonRecursive, 'Recursive': PySide2.QtCore.QMutex.RecursionMode.Recursive}
Recursive = PySide2.QtCore.QMutex.RecursionMode.Recursive
__enter__()[source]

Enter context.

Returns:
Mutex

This mutex object itself.

__exit__(*args)[source]

Exit context.

Parameters:
*args

Context arguments (type, value, traceback) passed to the method.

acquire(blocking: bool | None = True, timeout: int | float | None = -1) bool[source]

Mimics threading.Lock.acquire() to allow this class as a drop-in replacement.

Parameters:
blockingbool, optional

If True, this method will block until the mutex is locked (up to <timeout> seconds). If False, this method will return immediately regardless of the lock status. Default is True.

timeoutfloat, optional

Timeout in seconds specifying the maximum wait time for the mutex to be able to lock. Negative numbers correspond to infinite wait time. This parameter is ignored if blocking is False. Default is -1.0.

isRecursive(self) bool
lock(self) None
release() None[source]

Mimics threading.Lock.release() to allow this class as a drop-in replacement.

tryLock(self) bool
tryLock(self, timeout: int = 0) bool
try_lock(self) bool
unlock(self) None