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.
-
background_task
()[source]¶ Return a background callable for this task specification.
- Returns
Callable accepting arguments
send
andcancelled
. The callable can usesend
to send messages andcancelled
to check whether cancellation has been requested.- Return type
-
callable
= Callable()¶ The callable to be executed.
-
future
()[source]¶ Return a Future for the background task.
- Returns
future – Future object that can be used to monitor the status of the background task.
- Return type
-
kwargs
= Dict(Str())¶ Named arguments to be passed to the callable.
-
-
class
traits_futures.background_call.
CallBackgroundTask
(callable, args, kwargs)[source]¶ Bases:
object
Wrapper around the actual callable to be run. This wrapper provides the task that will be submitted to the concurrent.futures executor
-
class
traits_futures.background_call.
CallFuture
[source]¶ Bases:
traits_futures.base_future.BaseFuture
Object representing the front-end handle to a background call.
-
traits_futures.background_call.
submit_call
(executor, callable, *args, **kwargs)[source]¶ Convenience function to submit a background call to an executor.
- Parameters
executor (TraitsExecutor) – Executor to submit the task to.
callable (collections.abc.Callable) – Callable to execute in the background.
*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