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
finishin 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 tosubprocess.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
finishin its application, but as non-blocking Future.- Parameters:
- pool
Executor A concurrent.futures.Executor, usually a ThreadPoolExecutor.
- timeout
float,optional Time in seconds to wait, before returning to host process (None: unlimited).
- pool
- Returns:
Future[MessageBuffer]A Future object which will contain the result.
- finish(timeout=None)[source]¶
finish’s behavior is similar tosubprocess.dry_run.finishwaitstimeoutseconds, and forces termination after. By default, waits unlimitedtimeout=None. In either case, all messages in stdout and stderr pipes are read and together with the return code in a MessageBuffer object.- Parameters:
- timeout
float,optional Seconds to wait before forcing termination.
- timeout
- Returns:
MessageBufferA 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:
- file
IO.TextIO,optional The file or stream to which the output should be forwarded.
- encoding
str,optional Charset to encode.
- timeout
float,optional Interval to let the child process, before returning to the parent (this) process.
- out_prefix
str, default=”” String to prefix lines from the stdout output.
- err_prefix
str, default=”!” String to prefix lines from the stderr output.
- file
- Returns:
MessageBufferFull stdout, stderr and returncode.
- messages(timeout)[source]¶
- Parameters:
- timeout
float Time in seconds to wait, before checking if the process is still alive.
- timeout
- Yields:
MessageBufferA 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
finishin 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 tosubprocess.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