state_machine_db package

Submodules

state_machine_db.state_machine module

This module implements a state machine that waits for flags to jump from state to state until it is finished

class state_machine_db.state_machine.StateMachine(sm_database_path, activity_id)

Bases: threading.Thread

Implements a totally configurable state machine

Parameters:
  • sm_database_path (str) – path to the sqlite database
  • activity_id (str) – identifier for the current state machine instance
static check_if_thread_alive(activity_id)

Checks if there is a thread related to activity_id

Parameters:activity_id (str) – identifier for the current state machine instance
Returns:True if there is a thread, False otherwise
static get_sm_alive_threads()

Get info about all running threads related to state machine

Returns:A dictionary containing the name of each running thread and its thread object
get_updated_states()

This method must be implemented in the child class and return, after an update in the update_flag, a list of updated states

run()

Initiates the thread that effectivelly implements the state machine. A change of state must be sinalized by a flag (update, must be True) The final state must be sinalized by a flag (is_finished, must be True)

Module contents