biotite.application.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.

start()[source]

Start the application run and set its state to RUNNING. This can only be done from the CREATED state.

join(timeout=None)[source]

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:
timeout : float, 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.

cancel()[source]

Cancel the application when in RUNNING or FINISHED state.

get_app_state()[source]

Get the current app state.

Returns:
app_state : AppState

The current app state.

run()[source]

Commence the application run. Called in start().

PROTECTED: Override when inheriting.

is_finished()[source]

Check if the application has finished.

PROTECTED: Override when inheriting.

Returns:
finished : bool

True of the application has finished, false otherwise

wait_interval()[source]

The time interval of is_finished() calls in the joining process.

PROTECTED: Override when inheriting.

Returns:
interval : float

Time (in seconds) between calls of is_finished() in join()

evaluate()[source]

Evaluate application results. Called in join().

PROTECTED: Override when inheriting.

clean_up()[source]

Do clean up work after the application terminates.

PROTECTED: Optionally override when inheriting.