traits_futures.background_call module

Background task consisting of a simple callable.

class traits_futures.background_call.BackgroundCall[source]

Bases: traits.has_traits.HasStrictTraits

Object representing the background call to be executed.

args = Tuple()

Positional arguments to be passed to the callable.

callable = Callable()

The callable to be executed.

future(cancel)[source]

Return a Future for the background task.

Parameters

cancel – Zero-argument callable, returning no useful result. The returned future’s cancel method should call this to request cancellation of the associated background task.

Returns

future – Future object that can be used to monitor the status of the background task.

Return type

CallFuture

kwargs = Dict(Str())

Named arguments to be passed to the callable.

task()[source]

Return a background callable for this task specification.

Returns

Callable accepting arguments send and cancelled. The callable can use send to send messages and cancelled to check whether cancellation has been requested.

Return type

CallTask

class traits_futures.background_call.CallFuture[source]

Bases: traits_futures.base_future.BaseFuture

Object representing the front-end handle to a background call.

class traits_futures.background_call.CallTask(callable, args, kwargs)[source]

Bases: traits_futures.base_future.BaseTask

Wrapper around the actual callable to be run. This wrapper provides the task that will be submitted to the concurrent.futures executor

run()[source]

Run the body of the background task.

Returns

any – May return any object. That object will be delivered to the future’s result attribute.

Return type

object

traits_futures.background_call.submit_call(executor, callable, *args, **kwargs)[source]

Submit a simple call to an executor.

Parameters
  • executor (TraitsExecutor) – Executor to submit the task to. This argument should always be passed by position rather than by name. Future versions of the library may enforce this restriction.

  • callable – Callable to execute in the background. This argument should always be passed by position rather than by name. Future versions of the library may enforce this restriction.

  • *args – Positional arguments to pass to the callable.

  • **kwargs – Named arguments to pass to the callable.

Returns

future – Object representing the state of the background call.

Return type

CallFuture