Engine

class scine_chemoton.engine.Engine(credentials, fork=True)[source]

The Engine is a small class starting and stopping potentially infinitely running code acting on a reaction network in a database. All continuous jobs are called Gears (scine_chemoton.gears.Gears), see the appropriate part of this documentation for existing examples.

Parameters:
credentialsdb.Credentials (Scine::Database::Credentials)

The credentials to a database storing a reaction network. The started process will connect and interact with the referenced database.

forkbool

If true, this will cause the Engine to start the process defined by the given Gear with a fork, meaning it will run in a separate thread.

get_number_of_gear_loops()[source]
Return type:

int

is_running()[source]
Return type:

bool

Returns:
bool

True if the engine is running, False otherwise.

join(timeout=None)[source]

In case of a forked job this will wait for the graceful exit of the job. If the process has not been signalled to stop, this will also initiate the stop.

run(single=False)[source]

Starts turning the given Gear (scine_chemoton.gears.Gears).

Parameters:
singlebool

If true, runs only a single iteration of the Gear’s loop. Default: false, meaning endless repetition of the loop.

Raises:
AttributeError

If no gear was added to the engine, prior to starting it.

set_gear(gear)[source]
Return type:

None

Parameters:
gearGear (scine_chemoton.gears.Gears)

The gear to be used when starting this engine.

stop()[source]

In case of a forked job, this will send an interrupt signal to the forked process, leading to a graceful exit.

Return type:

None

terminate()[source]

In case of a forked job, this will terminate the forked process.

Return type:

None

Notes

The job will NOT be stopped gracefully.

class scine_chemoton.engine.EngineHandler(engines, signals=None)[source]

A class that takes a list of engines and an optional list of signals. It takes care that all given engines are stopped and their forked processes are joined when one of the signals is sent to the process. No further actions are required, the class must simply be kept in scope.

append(other)[source]
run(single=False)[source]
Return type:

None

stop_and_join()[source]
Return type:

None

wait_for_stop_signal(input_=<built-in function input>)[source]
Return type:

None