traits_futures.i_pingee module¶
Interface for the toolkit-specific pingee and pinger classes.
-
class
traits_futures.i_pingee.
IPingee
[source]¶ Bases:
abc.ABC
Interface for toolkit-specific pingee classes.
An IPingee instance provides a toolkit-specific cross-thread pinging mechanism. The pingee is owned by the main thread, but may be shared with background threads for the sole purpose of allowing those background threads to create linked pingers.
Whenever a ping is received from a linked
IPinger
instance, the pingee ensures that under a running event loop, theon_ping
callable is eventually called. Theon_ping
callable will always be called on the main thread.- Parameters
on_ping – Zero-argument callable that’s called on the main thread every time a ping is received.
-
abstract
connect
()[source]¶ Prepare pingee to receive pings.
Not thread-safe. This method should only be called in the main thread.
-
abstract
disconnect
()[source]¶ Disconnect from the on_ping callable.
Pings that are received after this method is called will be ignored.
Not thread-safe. This method should only be called in the main thread.
-
abstract
pinger
()[source]¶ 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.
- Returns
pinger – New pinger, linked to this pingee.
- Return type
-
class
traits_futures.i_pingee.
IPinger
[source]¶ Bases:
abc.ABC
Interface for toolkit-specific pinger classes.
An IPinger instance emits pings targeting a particular IPingee instance.
- Parameters
pingee (
IPingee
) – The target receiver for the pings. The receiver should already be connected.
-
abstract
connect
()[source]¶ Connect to the ping receiver. No pings should be sent before this method is called.