Package kiwi :: Module tasklet :: Class Tasklet
[frames | no frames]

Type Tasklet

object --+
         |
        Tasklet


An object that launches and manages a tasklet.
Method Summary
  add_join_callback(self, callback)
Add a callable to be invoked when the tasklet finishes.
  get_message_actions(self)
Dictionary mapping message names to actions ('accept' or 'discard' or 'defer').
  remove_join_callback(self, handle)
Remove a join callback previously added with add_join_callback
  run(self)
Method that executes the task.
  send_message(self, message)
Send a message to be received by the tasklet as an event.
  wait_condition_fired(self, triggered_cond)
Method that should be called when a wait condition fires

Property Summary
  message_actions

Instance Variable Summary
  return_value: the value returned by the task function, or None.
  state: current execution state of the tasklet, one of the STATE_* contants.

Class Variable Summary
int STATE_MSGSEND: the tasklet function is currently sending a message
int STATE_RUNNING: the tasklet function is currently executing code
int STATE_SUSPENDED: the tasklet function is currently waiting for an event
int STATE_ZOMBIE: the tasklet function has ended

Method Details

add_join_callback(self, callback)

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)

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.

get_message_actions(self)

Dictionary mapping message names to actions ('accept' or 'discard' or 'defer'). Should normally not be accessed directly by the programmer.

remove_join_callback(self, handle)

Remove a join callback previously added with add_join_callback

run(self)

Method that executes the task.

Should be overridden in a subclass if no generator is passed into the constructor.

send_message(self, message)

Send a message to be received by the tasklet as an event.

Warning: Don't call this from another tasklet, only from the main loop! To send a message from another tasklet, yield a Message with a correctly set 'dest' parameter.

wait_condition_fired(self, triggered_cond)

Method that should be called when a wait condition fires

Property Details

message_actions

Get Method:
get_message_actions(self)

Instance Variable Details

return_value

the value returned by the task function, or None.

state

current execution state of the tasklet, one of the STATE_* contants.

Class Variable Details

STATE_MSGSEND

the tasklet function is currently sending a message
Type:
int
Value:
2                                                                     

STATE_RUNNING

the tasklet function is currently executing code
Type:
int
Value:
0                                                                     

STATE_SUSPENDED

the tasklet function is currently waiting for an event
Type:
int
Value:
1                                                                     

STATE_ZOMBIE

the tasklet function has ended
Type:
int
Value:
3                                                                     

Generated by Epydoc 2.1 on Fri Sep 15 11:53:23 2006 http://epydoc.sf.net