Async – async handle

class uv.Async(loop=None, on_wakeup=None)[source]

Async handles are able to wakeup the event loop of another thread and run the given callback in the event loop’s thread. Although the uv.Async.send() method is thread-safe the constructor is not. To run a given callback in the event loop’s thread without creating an uv.Async handle use uv.Loop.call_later().

on_wakeup

Callback which should run in the event loop’s thread after the event loop has been woken up.

on_wakeup(async_handle)
Parameters:async_handle (uv.Async) – handle the call originates from
Readonly:False
Type:Callable[[uv.Async], None]
send(on_wakeup=None)[source]

Wakeup the event loop and run the callback afterwards. Multiple calls to this method are coalesced if they happen before the callback has been called. This means not every call will yield an execution of the callback. It is safe to call this method form outside the event loop’s thread.

Raises:
  • uv.UVError – error while trying to wakeup the event loop
  • uv.ClosedHandleError – handle has already been closed or is closing
Parameters:

on_wakeup (Callable[[uv.Async], None]) – callback which should run in the event loop’s thread after the event loop has been woken up (overrides the current callback if specified)