traits_futures.background_iteration module¶
Background task that sends results from an iteration.
- class traits_futures.background_iteration.BackgroundIteration[source]¶
Bases:
HasStrictTraits
Object representing the background iteration to be executed.
- args = Tuple()¶
Positional arguments to be passed to the callable.
- callable = Callable()¶
The callable to be executed. This should return something iterable.
- 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:
- 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.IterationFuture[source]¶
Bases:
BaseFuture
Foreground representation of an iteration executing in the background.
- result_event = Event()¶
Event fired whenever a result arrives from the background iteration.
- class traits_futures.background_iteration.IterationTask(callable, args, kwargs)[source]¶
Bases:
BaseTask
Iteration to be executed in the background.
- traits_futures.background_iteration.submit_iteration(executor, callable, *args, **kwargs)[source]¶
Submit an iteration 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 returning an iterator when called with the given arguments. 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 iteration.
- Return type: