Application#
- class biotite.application.Application[source]#
Bases:
objectThis class is a wrapper around an external piece of runnable software in any sense. Subclasses of this abstract base class specify the respective kind of software and the way of interacting with it.
Every
Applicationruns through a different app states (instances of enumAppState) from its creation until its termination.Directly after its instantiation the app is in the CREATED state. In this state further parameters can be set for the application run. After the user calls the
start()method, the app state is set to RUNNING and theApplicationtype specificrun()method is called. When the application finishes the AppState changes to FINISHED. This is checked via theApplicationtype specificis_finished()method. The user can now call thejoin()method, concluding the application in the JOINED state and making the results of the application accessible by executing theApplicationtype specificevaluate()method. Furthermore this executes theApplicationtype specificclean_up()method.join()can even be called in the RUNNING state: This will constantly checkis_finished()and will directly go into the JOINED state as soon as the application reaches the FINISHED state. Calling thecancel()method while the application is RUNNING or FINISHED leaves the application in the CANCELLED state. This triggers theclean_up()method, too, but there are no accessible results. If a method is called in an unsuitable app state, anAppStateErroris called.The application run behaves like an additional thread: Between the call of
start()andjoin()other Python code can be executed, while the application runs in the background.- cancel()#
Cancel the application when in RUNNING or FINISHED state.
- clean_up()#
Do clean up work after the application terminates.
PROTECTED: Optionally override when inheriting.
- abstractmethod evaluate()#
Evaluate application results. Called in
join().PROTECTED: Override when inheriting.
- get_app_state()#
Get the current app state.
- Returns:
- app_stateAppState
The current app state.
- abstractmethod is_finished()#
Check if the application has finished.
PROTECTED: Override when inheriting.
- Returns:
- finishedbool
True of the application has finished, false otherwise.
- join(timeout=None)#
Conclude the application run and set its state to JOINED. This can only be done from the RUNNING or FINISHED state.
If the application is FINISHED the joining process happens immediately, if otherwise the application is RUNNING, this method waits until the application is FINISHED.
- Parameters:
- timeoutfloat, optional
If this parameter is specified, the
Applicationonly waits for finishing until this value (in seconds) runs out. After this time is exceeded aTimeoutErroris raised and the application is cancelled.
- Raises:
- TimeoutError
If the joining process exceeds the timeout value.
- abstractmethod run()#
Commence the application run. Called in
start().PROTECTED: Override when inheriting.
- start()#
Start the application run and set its state to RUNNING. This can only be done from the CREATED state.
- abstractmethod wait_interval()#
The time interval of
is_finished()calls in the joining process.PROTECTED: Override when inheriting.
- Returns:
- intervalfloat
Time (in seconds) between calls of
is_finished()injoin().