FastSurferCNN.utils.run_tools

class FastSurferCNN.utils.run_tools.MessageBuffer(out=b'', err=b'', retcode=None, runtime=0.0)[source]

MessageBuffer class.

Attributes

retcode

Methods

err_str

out_str

class FastSurferCNN.utils.run_tools.Popen(*args, **kwargs)[source]

Extension of subprocess.Popen for convenience.

Attributes

universal_newlines

Methods

as_future(pool[, timeout])

Similar to finish in its application, but as non-blocking Future.

communicate([input, timeout])

Interact with process: Send data to stdin and close it.

finish([timeout])

finish's behavior is similar to subprocess.dry_run.

forward_output([file, encoding, timeout, ...])

Forwards the stdout and stderr every timeout to file.

kill()

Kill the process with SIGKILL

messages(timeout)

poll()

Check if child process has terminated.

send_signal(sig)

Send a signal to the process.

terminate()

Terminate the process with SIGTERM

wait([timeout])

Wait for child process to terminate; returns self.returncode.

async_finish

next_message

as_future(pool, timeout=None)[source]

Similar to finish in its application, but as non-blocking Future.

Parameters:
poolExecutor

A concurrent.futures.Executor, usually a ThreadPoolExecutor.

timeoutfloat, optional

Time in seconds to wait, before returning to host process (None: unlimited).

Returns:
Future[MessageBuffer]

A Future object which will contain the result.

See also

finish

The finish method provides similar functionality.

finish(timeout=None)[source]

finish’s behavior is similar to subprocess.dry_run.

finish waits timeout seconds, and forces termination after. By default, waits unlimited timeout=None. In either case, all messages in stdout and stderr pipes are read and together with the return code in a MessageBuffer object.

Parameters:
timeoutfloat, optional

Seconds to wait before forcing termination.

Returns:
MessageBuffer

A MessageBuffer object with the content of the stdout and stderr pipes.

forward_output(file=None, encoding=None, timeout=None, out_prefix='', err_prefix='!')[source]

Forwards the stdout and stderr every timeout to file. Returns the full output as a MessageBuffer object.

Parameters:
fileIO.TextIO, optional

The file or stream to which the output should be forwarded.

encodingstr, optional

Charset to encode.

timeoutfloat, optional

Interval to let the child process, before returning to the parent (this) process.

out_prefixstr, default=””

String to prefix lines from the stdout output.

err_prefixstr, default=”!”

String to prefix lines from the stderr output.

Returns:
MessageBuffer

Full stdout, stderr and returncode.

messages(timeout)[source]
Parameters:
timeoutfloat

Time in seconds to wait, before checking if the process is still alive.

Yields:
MessageBuffer

A MessageBuffer object with stdout and stderr information.

class FastSurferCNN.utils.run_tools.PyPopen(args, *_args, **kwargs)[source]

Attributes

universal_newlines

Methods

as_future(pool[, timeout])

Similar to finish in its application, but as non-blocking Future.

communicate([input, timeout])

Interact with process: Send data to stdin and close it.

finish([timeout])

finish's behavior is similar to subprocess.dry_run.

forward_output([file, encoding, timeout, ...])

Forwards the stdout and stderr every timeout to file.

kill()

Kill the process with SIGKILL

messages(timeout)

poll()

Check if child process has terminated.

send_signal(sig)

Send a signal to the process.

terminate()

Terminate the process with SIGTERM

wait([timeout])

Wait for child process to terminate; returns self.returncode.

async_finish

next_message