mode.utils.locks
Modern versions of asyncio.locks.
asyncio primitives call get_event_loop()
in init,
which makes them unsuitable for use in programs that don't
want to pass the loop around.
Event
Asynchronous equivalent to threading.Event.
Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false.
Source code in mode/utils/locks.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
clear()
Reset the internal flag to false.
Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.
Source code in mode/utils/locks.py
57 58 59 60 61 62 63 |
|
is_set()
Return True if and only if the internal flag is true.
Source code in mode/utils/locks.py
40 41 42 |
|
set()
Set the internal flag to true.
All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all.
Source code in mode/utils/locks.py
44 45 46 47 48 49 50 51 52 53 54 55 |
|
wait()
async
Block until the internal flag is true.
If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True.
Source code in mode/utils/locks.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|