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.
- 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:
- Parameters:
- gearGear (scine_chemoton.gears.Gears)
The gear to be used when starting this engine.
- 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.