momotor.shared.exlock

Implementation of an exclusive lock.

A subclass of aiorwlock.RWLock

Class documentation

ExLock

class momotor.shared.exlock.ExLock(*, fast=False, loop=None)

A subclass of aiorwlock.RWLock

An ExLock maintains a pair of associated locks, one for read-only operations and one for writing. The read lock may be held simultaneously by multiple reader tasks, so long as there are no writers. The write lock is exclusive.

get(exclusive)

Get either the reader or writer lock, depending on the value of exclusive

Parameters

exclusive (bool) – if False, requests the reader lock, otherwise the writer lock

Return type

Union[_ReaderLock, _WriterLock]

Returns

the requested lock