Interface for a job specification. The job specification is the object that the TraitsExecutor knows how to deal with.
Specify background task callable and foreground future for a task.
An object implementing the ITaskSpecification interface describes how to create a background task and a corresponding foreground future to execute a particular type of background task. It’s consumed by the TraitsExecutor when submitting background tasks, and implemented by BackgroundCall, BackgroundIteration and others.
Return the callable that will be invoked as the background task.
This callable should be pickleable and should have the signature
Any exception raised while executing the callable, or result returned by the callable, will be recorded in the corresponding future.
sendargument can be used by the background task to send messages back to the main thread of execution. It’s a callable that can be used either in the form
send(message_type)or in the form
send(message_type, message_args). Here
message_typeis a simple constant (typically a string), and
message_argsis a single Python object containing optional arguments for the message. The arguments to
sendshould typically be both immutable and pickleable.
sendreturns no useful result.
cancelledargument may be used by the background task to check whether cancellation has been requested. When called with no arguments, it returns either
Trueto indicate that cancellation has been requested, or
Note that there’s no obligation for the background task to check the cancellation status.
- Return type