ibex_bluesky_core.plan_stubs

Core plan stubs.

Members

call_sync

Call a synchronous user function in a plan, and returns the result of that call.

ibex_bluesky_core.plan_stubs.call_sync(func: ~typing.Callable[[~P], ~ibex_bluesky_core.plan_stubs.T], *args: ~typing.~P, **kwargs: ~typing.~P) Generator[Msg, None, T][source]

Call a synchronous user function in a plan, and returns the result of that call.

Attempts to guard against the most common pitfalls of naive implementations, for example:

  • Blocking the whole event loop

  • Breaking keyboard interrupt handling

  • Not clearing the active checkpoint

It does not necessarily guard against all possible cases, and as such it is recommended to use native bluesky functionality wherever possible in preference to this plan stub. This should be seen as an escape-hatch.

The wrapped function will be run in a new thread.

This plan stub will clear any active checkpoints before running the external code, because in general the external code is not safe to re-run later once it has started (e.g. it may have done relative sets, or may have started some external process). This means that if a plan is interrupted at any point between a call_sync and the next checkpoint, the plan cannot be resumed - in this case bluesky.utils.FailedPause will appear in the ctrl-c stack trace.

Parameters:
  • func – A callable to run.

  • args – Arbitrary arguments to be passed to the wrapped function

  • kwargs – Arbitrary keyword arguments to be passed to the wrapped function