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, the on_ping callable is eventually called. The on_ping callable will always be called on the main thread.

Parameters

on_ping (callable) – 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]

Undo any connections made in the connect method.

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 on a connected pingee.

Returns

pinger – New pinger, linked to this pingee.

Return type

IPinger

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.

abstract disconnect()[source]

Disconnect from the ping receiver. No pings should be sent after calling this method.

abstract ping()[source]

Send a ping to the receiver.