asyncio.Event

class asyncio.Event(*, loop=None)

An Event implementation, 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.

This class is not thread safe.

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.

is_set()

Return True if and only if the internal flag is true.

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.

coroutine wait()

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.

This method is a coroutine.

doc_python
2016-10-07 17:26:46
Comments
Leave a Comment

Please login to continue.