Qt 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.qt.pingee.Pingee(*args: Any, **kwargs: Any)¶
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.
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.qt.pingee.Pinger(pingee)¶
Ping emitter, which can send pings to a receiver in a thread-safe manner.
Pingee) – The target receiver for the pings. The receiver must already be connected.
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.