TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/alex-ber/AlexBerUtils/llms.txt
Use this file to discover all available pages before exploring further.
alexber.utils.processinvokes module wraps subprocess.run() with real-time log streaming. Long-running subprocesses write their output line-by-line to a Python logger instead of buffering until completion.
Quick start
Call initConfig() once at startup
initConfig() is called automatically when the module is imported, so this step is only needed if you want to override the defaults.run_sub_process(*args, **kwargs)
Runs a subprocess and streams its stdout and stderr to a logger.
This is a higher-level wrapper around subprocess.run(). The subprocess is executed in a thread pool so its output can be consumed line-by-line without deadlocks.
Parameters
| Parameter | Description |
|---|---|
*args | Positional arguments forwarded as the command and its arguments to subprocess.run(). |
kwargs | Dict of keyword arguments forwarded to subprocess.run() (e.g. cwd, env). |
logPipe | Dict controlling the pipe object. Accepts cls (class or dotted string, default LogPipe) and kwargs (passed to the pipe constructor, e.g. logName, logLevel). |
logSubprocess | Dict controlling the subprocess coordinator. Accepts cls (class or dotted string, default LogSubProcessCall) and kwargs. |
Default subprocess.run() settings
Unless overridden via kwargs, the following defaults are applied:
| Setting | Value | Effect |
|---|---|---|
stdout | log pipe | Subprocess output goes to the logger. |
stderr | subprocess.STDOUT | stderr is merged into stdout. |
text | True | Output is decoded using the system default encoding. |
bufsize | 1 | Line-buffered — each newline flushes immediately. |
check | True | Non-zero exit codes raise subprocess.CalledProcessError. |
initConfig(**kwargs)
Configures module-level defaults. Call this once from the main thread before using run_sub_process.
| Parameter | Default | Description |
|---|---|---|
default_log_name | 'alexber.utils.processinvokes' | Logger name used by LogPipe. |
default_log_level | logging.INFO | Log level for subprocess output lines. |
default_logpipe_cls | LogPipe | Class used to create the pipe. Can be a class or dotted string. |
default_log_subprocess_cls | LogSubProcessCall | Class used to coordinate the subprocess call. |
executor | {max_workers: 1, thread_name_prefix: 'processinvokes'} | Arguments forwarded to ThreadPoolExecutor. |
