Future#

class biotite.application_v2.Future[source]#

Bases: ABC, Generic[T]

A handle to an application run that may still be in progress.

Mirrors concurrent.futures.Future.

A Future is usually not created directly, but is returned by the respective method of an Application.

A subclass must implement _evaluate() to parse the finished run into its result object and _cleanup() to release the resources of the run.

cancel() → bool#

Abort the run.

Returns:
cancelledbool

True, if the run was cancelled, or False if it had already finished and could not be cancelled anymore.

cancelled() → bool#

Return True, if the run was cancelled.

Returns:
bool

True if the run was cancelled, False otherwise.

done() → bool#

Return True, if the run was cancelled or has finished.

Returns:
bool

True if the run was cancelled or has finished, False otherwise.

Notes

A finished run may still raise an exception in result().

exception(timeout: float | None = None) → Exception | None#

Wait for the run to finish and return the exception it raised.

Parameters:
timeoutfloat, optional

The maximum number of seconds to wait. By default, the method waits indefinitely.

Returns:
exceptionException or None

The exception raised by the run, or None if it finished without error.

Raises:
TimeoutError

If the run does not finish within timeout seconds.

CancelledError

If the run was cancelled.

result(timeout: float | None = None) → T#

Wait for the run to finish and return its result.

Parameters:
timeoutfloat, optional

The maximum number of seconds to wait. By default, the method waits indefinitely.

Returns:
resultobject

The result object of the run.

Raises:
TimeoutError

If the run does not finish within timeout seconds.

CancelledError

If the run was cancelled.

running() → bool#

Return True, if the run is currently in progress.

Returns:
bool

True if the run is currently in progress, False otherwise.