Application#

class biotite.application.Application[source]#

Bases: object

This 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 Application runs through a different app states (instances of enum AppState) 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 the Application type specific run() method is called. When the application finishes the AppState changes to FINISHED. This is checked via the Application type specific is_finished() method. The user can now call the join() method, concluding the application in the JOINED state and making the results of the application accessible by executing the Application type specific evaluate() method. Furthermore this executes the Application type specific clean_up() method. join() can even be called in the RUNNING state: This will constantly check is_finished() and will directly go into the JOINED state as soon as the application reaches the FINISHED state. Calling the cancel() method while the application is RUNNING or FINISHED leaves the application in the CANCELLED state. This triggers the clean_up() method, too, but there are no accessible results. If a method is called in an unsuitable app state, an AppStateError is called.

The application run behaves like an additional thread: Between the call of start() and join() 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.

abstract 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.

abstract 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 Application only waits for finishing until this value (in seconds) runs out. After this time is exceeded a TimeoutError is raised and the application is cancelled.

Raises:
TimeoutError

If the joining process exceeds the timeout value.

abstract 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.

abstract 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() in join()