Skip to main content
Pause a lager python script mid-run, inspect the bench, then resume where the script left off. You can inspect it with ad-hoc lager commands or with a live Python prompt. This helps on a long test that reaches a known trouble spot. It also helps when you must check a device in an unknown state without killing and restarting the run. Introduced in lager 0.21.0.

Import

pause(label=None, *, timeout=None, interactive=False)

Blocks the script at the call site until it is resumed (or the timeout elapses).
When the line runs, the script prints a banner and stops:
pause() is a safe no-op when it can’t pause — when the script isn’t running under lager python (no breakpoint context), or when breakpoints are disabled. It never raises.

Resuming

A paused script can be resumed three ways:
  1. Press Enter in the terminal running the script (the foreground lager python session).
  2. lager python --continue <id> --box <box> — from any terminal, anywhere. Use the id from the banner. Handy when the script is detached or you’re already in another terminal.
  3. Auto-resume — after the timeout (default 300 s) the script continues on its own and logs that it did. This keeps an unattended or forgotten breakpoint from hanging a run.

Controlling the auto-resume timeout

The default is 300 seconds. Override it per breakpoint, per run, or disable it entirely:
Resolution order is timeout= argument → LAGER_BREAKPOINT_TIMEOUT env → 300 s default, so an explicit timeout= in the script wins over the env var.
lager python --timeout is a different setting. It is the script’s total runtime limit, and the box caps it at 300 s. It terminates the whole run when it elapses, whether the script is paused or not. Leave it at its default (0, unlimited) when you use long breakpoint pauses.

Interactive console

With pause(interactive=True), the breakpoint also opens a Python console running inside the paused script’s process, seeded with the variables in scope at the pause:
Connect to it from another terminal:
You can read any variable, evaluate expressions, and call functions the script defines. Ctrl+D disconnects (the script stays paused).
The console is for inspection. It operates on a snapshot of the script’s namespace. Changes that you make in the console do not carry back into the script when it resumes.

Inspecting hardware while paused

Because a paused script holds no box-wide lock, you can run normal lager commands against the bench from another terminal while it waits:
Two hardware rules to keep in mind, both a consequence of USB instruments allowing only one owner at a time:
  • A device the script itself has open is claimed by the paused process. Reading it from a second terminal returns a “device busy / claimed by another process” error. Read it through the --console instead — that runs in the same process and shares the open handle.
  • One net per physical instrument per process. Two nets on the same instrument cannot both be open at once in a single script. Examples are the two channels of one Rigol DP821, supply2/supply3, and the dual-role Keithley 2281S, supply1/battery1. Read them from separate terminals, or one at a time.

Built-in breakpoint()

Calling Python’s built-in breakpoint() in a lager python script triggers the same interactive pause as lager.pause():

Disabling breakpoints

Set LAGER_BREAKPOINTS to an off value. Every pause() and breakpoint() call then becomes a no-op, which gives a clean, non-interactive run of a script that still has breakpoints in it:
Accepts off, 0, false, or no (case-insensitive).

Full example

test.py:
Run it (terminal 1):
While it’s paused, check the bench (terminal 2):
Press Enter in terminal 1 (or run lager python --continue 7f3a…e9 --box mybox) and the script finishes: