selinon.storage_pool module

A pool that carries all database connections for workers.

class selinon.storage_pool.StoragePool(id_mapping, flow_name)[source]

Bases: object

A pool that carries all database connections for workers.

classmethod delete(flow_name, task_name, task_id)[source]

Delete task’s result from database which was configured to be used for desired task.

Parameters:
  • flow_name – flow in which the retrieval is taking place
  • task_name – name of task for which result should be deleted
  • task_id – task ID to uniquely identify task results
get(task_name)[source]

Retrieve data for task based on mapping for the current context.

Parameters:task_name – task’s name that we are retrieving data for
Returns:task’s result for the current context
classmethod get_connected_storage(storage_name)[source]

Retrieve connected storage based by its name stated in configuration.

Parameters:storage_name – name of storage
Returns:connected storage
classmethod get_storage_by_task_name(task_name)[source]

Get storage instance that was assigned to the given task.

Parameters:task_name – task’s name for which storage should be get
Return type:DataStorage
classmethod get_storage_name_by_task_name(task_name, graceful=False)[source]

Get name of storage that was assigned to the given task.

Parameters:
  • task_name – name of a task
  • graceful – return None instead of raising an exception
Returns:

storage name for task

classmethod retrieve(flow_name, task_name, task_id)[source]

Retrieve task’s result from database which was configured to be used for desired task.

Parameters:
  • flow_name – flow in which the retrieval is taking place
  • task_name – name of task for which result should be retrieved
  • task_id – task ID to uniquely identify task results
Returns:

task’s result

classmethod set(node_args, flow_name, task_name, task_id, result)[source]

Store result for task.

Parameters:
  • node_args – arguments that were passed to the node
  • flow_name – flow in which task was run
  • task_name – task that computed result
  • task_id – task id that computed result
  • result – result that should be stored
Returns:

result ID - a unique ID which can be used to reference task results

classmethod set_error(node_args, flow_name, task_name, task_id, exc_info)[source]

Store error information for task failure.

Parameters:
  • node_args – arguments that were passed to the node
  • flow_name – flow in which task was run
  • task_name – task that computed result
  • task_id – task id that computed result
  • exc_info – information about exception - tuple (type, value, traceback) as returned by sys.exc_info()
Returns:

true if error was stored in database - DataStorage.store_error() was called