kiwi.tasklet.Tasklet(object)
class documentationkiwi.tasklet
(View In Hierarchy)
An object that launches and manages a tasklet. @ivar state: current execution state of the tasklet, one of the STATE_* contants. @ivar return_value: the value returned by the task function, or None. @cvar STATE_RUNNING: the tasklet function is currently executing code @cvar STATE_SUSPENDED: the tasklet function is currently waiting for an event @cvar STATE_MSGSEND: the tasklet function is currently sending a message @cvar STATE_ZOMBIE: the tasklet function has ended
Method | __init__ | Launch a generator tasklet. |
Method | start | Starts the execution of the task, for use with tasklets created with start=False |
Method | get_message_actions | Dictionary mapping message names to actions ('accept' or 'discard' or 'defer'). Should normally not be accessed directly by the programmer. |
Method | run | Method that executes the task. |
Method | wait_condition_fired | Method that should be called when a wait condition fires |
Method | add_join_callback | Add a callable to be invoked when the tasklet finishes. Return a connection handle that can be used in remove_join_callback() |
Method | remove_join_callback | Remove a join callback previously added with L{add_join_callback} |
Method | send_message | Send a message to be received by the tasklet as an event. |
Method | _invoke | Undocumented |
Method | _next_round | Undocumented |
Method | _dispatch_message | get next message that a tasklet wants to receive; discard messages that should be discarded |
Method | _update_wait_conditions | disarm wait conditions removed and arm new wait conditions |
Method | _join | Undocumented |
Launch a generator tasklet. @param gen: a generator object that implements the tasklet main body @param start: whether to automatically start running the tasklet in the constructor If `gen` is omitted or None, L{run} should be overridden in a subclass.
Dictionary mapping message names to actions ('accept' or 'discard' or 'defer'). Should normally not be accessed directly by the programmer.
Method that executes the task. Should be overridden in a subclass if no generator is passed into the constructor. @note: do NOT call this method directly; it is meant to be called by the tasklet framework.
get next message that a tasklet wants to receive; discard messages that should be discarded
disarm wait conditions removed and arm new wait conditions
Method that should be called when a wait condition fires
Add a callable to be invoked when the tasklet finishes. Return a connection handle that can be used in remove_join_callback() The callback will be called like this:: callback(tasklet, retval, *extra_args) where tasklet is the tasklet that finished, and retval its return value (or None). When a join callback is invoked, it is automatically removed, so calling L{remove_join_callback} afterwards produces a KeyError exception.