Class k.t.Tasklet(object):

Part of kiwi.tasklet
An object that launches and manages a tasklet.
ivar statecurrent execution state of the tasklet, one of the STATE_* contants.
ivar return_valuethe value returned by the task function, or None.
cvar STATE_RUNNINGthe tasklet function is currently executing code
cvar STATE_SUSPENDEDthe tasklet function is currently waiting for an event
cvar STATE_MSGSENDthe tasklet function is currently sending a message
cvar STATE_ZOMBIEthe tasklet function has ended
Function__init__
Launch a generator tasklet.
Functionstart
Starts the execution of the task, for use with tasklets
Functionget_message_actions
Dictionary mapping message names to actions ('accept' or
Functionrun
Method that executes the task.
Function_invokeUndocumented
Function_next_roundUndocumented
Function_dispatch_message
get next message that a tasklet wants to receive; discard
Function_update_wait_conditions
disarm wait conditions removed and arm new wait conditions
Functionwait_condition_fired
Method that should be called when a wait condition fires
Functionadd_join_callback
Add a callable to be invoked when the tasklet finishes.
Functionremove_join_callback
Remove a join callback previously added with add_join_callback
Function_joinUndocumented
Functionsend_message
Send a message to be received by the tasklet as an event.
def __init__(self, gen=None, start=True):
Launch a generator tasklet.
def start(self):
Starts the execution of the task, for use with tasklets created with start=False
def get_message_actions(self):
Dictionary mapping message names to actions ('accept' or 'discard' or 'defer'). Should normally not be accessed directly by the programmer.
def run(self):

Method that executes the task.

Should be overridden in a subclass if no generator is passed into the constructor.
def _invoke(self):
Undocumented
def _next_round(self):
Undocumented
def _dispatch_message(self):
get next message that a tasklet wants to receive; discard messages that should be discarded
def _update_wait_conditions(self, old_wait_list):
disarm wait conditions removed and arm new wait conditions
def wait_condition_fired(self, triggered_cond):
Method that should be called when a wait condition fires
def add_join_callback(self, callback, *extra_args):

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 remove_join_callback afterwards produces a KeyError exception.
def remove_join_callback(self, handle):
Remove a join callback previously added with add_join_callback
def _join(self, retval):
Undocumented
def send_message(self, message):
Send a message to be received by the tasklet as an event.