Skip to main content

logproc

Run a process and live log stdin and stdout.

Description

This experimental module allows you to run an external program in the background and to live capture and handle its standard output and standard error.

Each captured line of output is immediately forwarded to the logging system (or whatever handler you provide) so that you can immediately see the output if you are logging to console. Both an asynchronous and a synchronous API is provided.

Basic Usage

In the simplest case, just run execute(["ls", "-l"]), which will run ls -l and log its output with Python’s default logging system, using the logger id ls and the level INFO for stdout, WARNING for stderr.

If you already run an asynchronous event loop, you can use the asynchronous API by running await aexecute(["ls", "-l"]) instead.

For more details, see the API reference

Launching processes in parallel

Sometimes it is useful to launch multiple processes in parallel and capture their output as it appears, while still limiting the number of concurrent processes (e.g., to the number of available CPU cores). This is possible using map_unordered. E.g.,

async def render_graphs(folder: Path):
    commands = (["dot", "-Tsvg", "-o", fspath(file.with_suffix(".svg")), fspath(file)] 
                for file in folder.glob("*.dot"))
    async for result in map_unordered(aexecute, commands):
        # Process the result
        pass

calls dot for each *.dot file in the given folder, limiting the number of concurrent jobs to the number of available CPU cores.

Release files for logproc 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for logproc 0.3.1
File Size Uploaded
logproc-0.3.1.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for logproc 0.3.1
File Interpreter ABI Platform
logproc-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.0 kB

Release files / logproc-0.3.1.tar.gz

Download URL logproc-0.3.1.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c7e0ca7a6851801785298bf33b4d1db418f7a5de423ab52939cb292dfb0eed73
BLAKE2b-256 checksum
How to use checksums
daf612c6240655763b88c0a8a83ae75da20c2b0a77209cbe6a196d2a165e5552
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / logproc-0.3.1-py3-none-any.whl

Download URL logproc-0.3.1-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35571324f3570a0819ec9c2ce938ff9bcde21c79abd67d7fbcbf166cfbab4ae7
BLAKE2b-256 checksum
How to use checksums
d8c4114f68e29947ccad64ec3aa5914bd8dd2586ca6c5ad06e293e87960feb7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page