traits_futures.background_iteration module¶
Background task that sends results from an iteration.
-
class
traits_futures.background_iteration.
BackgroundIteration
[source]¶ Bases:
traits.has_traits.HasStrictTraits
Object representing the background iteration 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. This should return something iterable.
-
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.
-
-
traits_futures.background_iteration.
GENERATED
= 'generated'¶ Message sent whenever the iteration yields a result. The message argument is the result generated.
-
class
traits_futures.background_iteration.
IterationBackgroundTask
(callable, args, kwargs)[source]¶ Bases:
object
Iteration to be executed in the background.
-
class
traits_futures.background_iteration.
IterationFuture
[source]¶ Bases:
traits_futures.base_future.BaseFuture
Foreground representation of an iteration executing in the background.
-
result_event
= Event()¶ Event fired whenever a result arrives from the background iteration.
-
-
traits_futures.background_iteration.
submit_iteration
(executor, callable, *args, **kwargs)[source]¶ Convenience function to submit a background iteration to an executor.
- Parameters
executor (TraitsExecutor) – Executor to submit the task to.
callable (collections.abc.Callable) – Callable returning an iterator when called with the given arguments.
*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 iteration.
- Return type