Execution Contexts

Module:bonobo.execution.contexts

Execution Contexts are objects that wraps the stateless data-structures (graphs and nodes) during a job execution to keep an eye on their context/state (from the simplest things like i/o statistics to lifecycle and custom userland state).

class GraphExecutionContext(graph, plugins=None, services=None, dispatcher=None)[source]

Bases: object

NodeExecutionContextType

alias of bonobo.execution.contexts.node.NodeExecutionContext

PluginExecutionContextType

alias of bonobo.execution.contexts.plugin.PluginExecutionContext

create_node_execution_context_for(node)[source]
create_plugin_execution_context_for(plugin)[source]
dispatch(name)[source]
kill()[source]
register_plugins()[source]
start(starter=None)[source]
stop(stopper=None)[source]
tick(pause=True)[source]
unregister_plugins()[source]
write(*messages)[source]

Push a list of messages in the inputs of this graph’s inputs, matching the output of special node “BEGIN” in our graph.

TICK_PERIOD = 0.25
alive
started
stopped
class NodeExecutionContext(wrapped, *, parent=None, services=None, _input=None, _outputs=None)[source]

Bases: bonobo.execution.contexts.base.BaseContext, bonobo.util.statistics.WithStatistics

Node execution context has the responsibility fo storing the state of a transformation during its execution.

Parameters:
  • wrapped – wrapped transformation
  • parent – parent context, most probably a graph context
  • services – dict-like collection of services
  • _input – input queue (optional)
  • _outputs – output queues (optional)
error(exc_info, *, level=40)[source]
fatal(exc_info, *, level=50)[source]
get_input_fields()[source]
get_output_fields()[source]
get_service(name)[source]
loop()[source]

The actual infinite loop for this transformation.

send(*_output, _input=None)[source]
set_input_fields(fields, typename='Bag')[source]
set_input_type(input_type)[source]
set_output_fields(fields, typename='Bag')[source]
set_output_type(output_type)[source]
setdefault(attr, value)[source]
start()[source]

Starts this context, a.k.a the phase where you setup everything which will be necessary during the whole lifetime of a transformation.

The “ContextCurrifier” is in charge of setting up a decorating stack, that includes both services and context processors, and will call the actual node callable with additional parameters.

step()[source]

A single step in the loop.

Basically gets an input bag, send it to the node, interpret the results.

stop()[source]

Cleanup the context, after the loop ended.

write(*messages)[source]

Push a message list to this context’s input queue.

Parameters:value (mixed) – message
write_sync(*messages)[source]
input_type
output_type
class PluginExecutionContext(wrapped, *, parent=None)[source]

Bases: bonobo.execution.contexts.base.BaseContext

register()[source]
unregister()[source]
dispatcher