PostprocessFuture#
- class biotite.application_v2.PostprocessFuture(future: Future[T], postprocess_fn: Callable[[T], U])[source]#
Bases:
Future[U],Generic[T,U]A future applying a function to the result of another future.
The postprocessing function is called lazily and at most once when the postprocessed result is requested.
- Parameters:
- futureFuture
The input future.
- postprocess_fncallable
A function receiving the input result and returning the postprocessed result.
Notes
postprocess_fn is run in the same process as the caller, i.e. its call is blocking.
- 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.