Skip to main content

TmuxProcess

If you’re prototyping with multiple processes all trying to send debug prints to the same terminal, things can get very confusing.

TmuxProcess is an extension of the multiprocessing Process class which automatically sets up a tmux session with a separate tmux window for each process created. With standard output for each process linked to a separate window, it’s much easier to keep track of what each individual process is doing. (Standard input can also be tied to each separate window, so you can also send different commands to different processes.)

Requirements

tmux, and that’s it!

Installation

pip install tmuxprocess

Usage

If you only care about standard output being redirected:

from tmuxprocess import TmuxProcess
import time

def f(name):
    print("{} running".format(name))
    while True:
        print("{} sleeping".format(name))
        time.sleep(1)

p1 = TmuxProcess(target=f, args=("f1", ))
print("Run")
print("  tmux attach -t {}".format(p1.tmux_sess))
print("to interact with each process.")
p1.start()
p2 = TmuxProcess(target=f, args=("f2", ))
p2.start()

Input and output from the main process will remain on the launching terminal. When the first process is created, a new tmux session will be launched in the background, a new tmux window created in that session, and standard output redirected to that window. When the second process is created, a second tmux window will be created in the same session, and its standard output similarly redirected.

If you also want standard input redirection, initialise with mode='inout':

from tmuxprocess import TmuxProcess

def f(name):
    print("{} running".format(name))
    while True:
        s = input()
        print("{} read:".format(name), s)

p1 = TmuxProcess(target=f, mode='inout', args=("f1", ))
print("Run")
print("  tmux attach -t {}".format(p1.tmux_sess))
print("to interact with each process.")
p1.start()
p2 = TmuxProcess(target=f, mode='inout', args=("f2", ))
p2.start()

However, with this mode, because of the way that standard input redirection is implemented, note that you will have to manually kill the session once done.

Metadata

Release files for tmuxprocess 0.2.0

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

Source distribution (sdist)

Source distribution for tmuxprocess 0.2.0
File Size Uploaded Provenance Actions
tmuxprocess-0.2.0.tar.gz 3.0 kB Without provenance Details for tmuxprocess-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 6.0 kB

Release files / tmuxprocess-0.2.0.tar.gz

Download URL tmuxprocess-0.2.0.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c14705107c6a796a18c7d374590c569a7e6393c53785caacc35909e0d5c94506
BLAKE2b-256 checksum
How to use checksums
f618ed6364e2d69494fab7a8271275f3b012e8ad48be407d1c3806659f14286e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

Release files / tmuxprocess-0.2.0-py3-none-any.whl

Download URL tmuxprocess-0.2.0-py3-none-any.whl
Size 3.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
649a291c4f2282d12da8406e0f3dea9ad8645a653d76c3670ff2f48b6457e560
BLAKE2b-256 checksum
How to use checksums
4a45fd9928527a68a2870f7fb95dd715d54bd9780e65578e9065ddcb36d2dbb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

Security for tmuxprocess 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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