Skip to main content
Pause a lager python script mid-run so you can inspect the bench with ad-hoc lager commands (or a live Python prompt), then resume where it left off. Useful for a long test that reaches a known trouble spot, or for checking on 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 — the script’s total runtime limit, capped at 300 s on the box — and it will terminate the whole run when it elapses, paused or not. Leave it at its default (0, unlimited) when using 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, so changes you make in the console do not carry back into the running 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 can’t both be open at once in a single script (e.g. the two channels of one Rigol DP821, supply2/supply3, or 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 to turn every pause() (and breakpoint()) into a no-op — useful for a clean, non-interactive run of a script that has breakpoints left 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: