Skip to content

Utilities

Public helpers around the core loop and pool calls.

mqdm.print

print(*args, **kw)

Print above the live bars — worker-safe, unlike the builtin print.

Takes the same arguments as rich.print and renders the output above the active progress display instead of tearing through it. Works from pool workers too: output is routed to the process that owns the display, so it lands in one coordinated place. Use this (or logging) instead of the builtin print while bars are live.

Example
for path in mqdm.mqdm(paths):
    if is_interesting(path):
        mqdm.print("found", path)   # stays above the bar

mqdm.sustain

sustain()

Keep the live progress display alive across this block.

A sequence of separate bars normally renders one at a time — each freezes into the scrollback as the next begins. Inside sustain() they stack and stay visible together as one growing panel, with print/logging streaming above them. Nestable.

Example
with mqdm.sustain():
    for i in range(3):
        for _ in mqdm.mqdm(range(4), desc=f"section {i}"):
            ...

mqdm.pause

pause(paused=True)

Freeze the live display for a with block, then resume — for using the terminal.

Holds the bars' state and stops rendering so you can safely drop into an interactive shell, pdb, a stack trace, or a prompt on a clean screen. As a context manager the bars resume automatically on exit; pause(False) resumes immediately.

Example
for i in mqdm.mqdm(range(100)):
    if something_wrong(i):
        with mqdm.pause():
            import IPython; IPython.embed()   # clean screen, bars frozen

mqdm.using

using(runtime: Runtime)

Make runtime the current runtime for the duration of this block.

Bars, pools, prints, and logging created inside pick it up automatically, so you can run a differently-configured display for a section without threading runtime= through every call. Thread-local and restored on exit — safe to nest, and it never leaks to other threads.

For a single, program-wide look, prefer :func:configure at startup; reach for this only when a specific block needs its own runtime.

Example
compact = mqdm.Runtime(backend_options={"columns": (
    "[progress.description]{task.description}",
    mqdm.columns.TwoToneColumn(bar_width=None),
)})
with mqdm.using(compact):
    for x in mqdm.mqdm(items):   # uses `compact`, no runtime= needed
        ...