LocalProcessFuture#
- class biotite.application_v2.LocalProcessFuture(process: Popen[bytes], command: list[str], evaluate: Callable[[bytes, bytes], T], cleanup: Callable[[], None] | None = None, parameters: Sequence[CLIFlag | CLIOption | CLIArgument] = ())[source]#
Bases:
Future[T]A
Futurebacked by a locally runningPopenprocess.- Parameters:
- processPopen
The already launched process.
- commandlist of str
The command line the process was launched with. Used for error messages and exposed via
command.- evaluatecallable
A callable that parses the finished run and returns the result object. It is passed the captured
STDOUT/STDERRand is invoked lazily and at most once, on the first call toresult()orexception().- cleanupcallable, optional
A zero-argument callable that releases resources (e.g. temporary files) of the run. It is invoked exactly once: after evaluation, on cancellation or on destruction, whichever comes first.
- parameterssequence of CLIParameter, optional
The original command line parameters. They are retained for the lifetime of the future so resources represented by an argument or option remain alive.
- Attributes:
- commandstr
The command line the process was launched with.
- 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.
- stderr(timeout: float | None = None) bytes#
Wait for the run to finish and return the captured standard error.
- Parameters:
- timeoutfloat, optional
The maximum number of seconds to wait. By default, the method waits indefinitely.
- Returns:
- stderrbytes
The captured standard error as raw bytes.
- Raises:
- TimeoutError
If the run does not finish within timeout seconds.
- CancelledError
If the run was cancelled.
- stdout(timeout: float | None = None) bytes#
Wait for the run to finish and return the captured standard output.
- Parameters:
- timeoutfloat, optional
The maximum number of seconds to wait. By default, the method waits indefinitely.
- Returns:
- stdoutbytes
The captured standard output as raw bytes.
- Raises:
- TimeoutError
If the run does not finish within timeout seconds.
- CancelledError
If the run was cancelled.