traits_futures.null.message_router module

Message routing for the Qt toolkit.

class traits_futures.null.message_router.MessageReceiver[source]

Bases: traits.has_traits.HasStrictTraits

Main-thread object that receives messages from a MessageSender.

message = Event(Any())

Event fired when a message is received from the paired sender.

class traits_futures.null.message_router.MessageRouter[source]

Bases: traits.has_traits.HasStrictTraits

Router for messages, sent by means of Qt signals and slots.

Requires the event loop to be running in order for messages to arrive.

close_pipe(sender, receiver)[source]

Close an unused pipe.

connect()[source]

Prepare router for routing.

disconnect()[source]

Undo any connections made by the connect call.

pipe()[source]

Create a (sender, receiver) pair for sending messages.

Returns

  • sender (MessageSender) – Object to be passed to the background task to send messages.

  • receiver (MessageReceiver) – Object to be kept in the foreground which reacts to messages.

receiver_done = Event(Instance(MessageReceiver))

Event fired when a receiver is dropped from the routing table.

class traits_futures.null.message_router.MessageSender(connection_id, asyncio_event_loop, route_message, message_queue)[source]

Bases: object

Object allowing the worker to send messages.

This class will be instantiated in the main thread, but passed to the worker thread to allow the worker to communicate back to the main thread.

Only the worker thread should use the send method, and only inside a “with sender:” block.

send(message)[source]

Send a message to the router.