Skip to content

Add waitfor CLI command - #28

Merged
prkrtg merged 3 commits into
mainfrom
pgupta/wait_for
Sep 14, 2026
Merged

prkrtg merged 3 commits into
mainfrom
pgupta/wait_for

Conversation

@prkrtg

@prkrtg prkrtg commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Adds the ability to block until a keyword satisfies a condition, modelled on
KTL's waitFor.
https://www2.keck.hawaii.edu/software/KTLPython/examples.html#using-waitfor

Because libby daemons don't broadcast keyword changes, wait_for polls the
keyword over RPC rather than waiting on a monitor; --poll sets the interval
(default 0.1s)

Example usage:

$ libby waitfor '$hsfei.pickoff.ismoving == false' --timeout 30
hsfei.pickoff.ismoving = False (satisfied after 4.2s)
$ libby waitfor '$hsfei.pickoff.positionvalue > 15' --timeout 30 --json
{
  "ok": true,
  "expression": "$hsfei.pickoff.positionvalue > 15",
  "satisfied": true,
  "qualified": "hsfei.pickoff.positionvalue",
  "value": 79.0,
  "elapsed_s": 6.104,
  "polls": 62
}

via Python

if client.wait_for("$hsfei.pickoff.positionvalue > 15", timeout=5):
    print("pickoff exceeded 15 within 5 seconds")

client.wait_for("$ismoving == false", 30, service="hsfei.pickoff")

@mikelangmayr mikelangmayr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@prkrtg
prkrtg merged commit c7d5849 into main Sep 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants