traits_futures.wrappers module

Wrappers for the background task callable and the foreground future.

These are used by the TraitsExecutor machinery.

class traits_futures.wrappers.FutureWrapper[source]

Bases: traits.has_traits.HasStrictTraits

Wrapper for the IFuture.

Passes on messages received for this future.

done = Bool(False)

Bool recording whether the future has completed or not. The executor listens to this trait to decide when it can clean up its own internal state.

future = Instance(IFuture)

The Traits Futures future being wrapped

receiver = Instance(HasTraits)

Object that receives messages from the background task.

traits_futures.wrappers.run_background_task(task, sender, cancelled)[source]

Wrapper for callables submitted to the underlying executor.

Parameters
  • task – Callable representing the background task. This will be called with arguments send and cancelled.

  • sender (IMessageSender) – Object used to send messages.

  • cancelled – Zero-argument callable returning bool. This can be called to check whether cancellation has been requested.