asyncio cross-thread pinger.
This module provides a way for a background thread to request that the main thread execute a (fixed, parameterless) callback.
- class traits_futures.asyncio.pingee.Pingee(on_ping, event_loop)¶
Receiver for pings.
Whenever a ping is received from a linked Pinger, the receiver calls the given fixed parameterless callable.
The ping receiver must be connected (using the
connect) method before use, and should call
disconnectwhen it’s no longer expected to receive pings.
on_ping – Zero-argument callable that’s called on the main thread every time a ping is received.
asyncio.AbstractEventLoop) – The asyncio event loop that pings will be sent to.
Prepare Pingee to receive pings.
Disconnect from the on_ping callable.
Create and return a new pinger linked to this pingee.
This method is thread-safe. Typically the pingee will be passed to a background thread, and this method used within that background thread to create a pinger.
This method should only be called after the ‘connect’ method has been called.
pinger – New pinger, linked to this pingee.
- Return type
- class traits_futures.asyncio.pingee.Pinger(pingee, event_loop)¶
Ping emitter, which can send pings to a receiver in a thread-safe manner.
Connect to the ping receiver. No pings should be sent until this function is called.
Disconnect from the ping receiver. No pings should be sent after calling this function.
Send a ping to the receiver.