ibex_bluesky_core.plan_stubs

Core plan stubs.

Members

call_qt_aware

Call a matplotlib function in a Qt-aware context, from within a plan.

call_sync

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

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

Call a matplotlib function in a Qt-aware context, from within a plan.

If matplotlib is using a Qt backend then UI operations are run on the Qt thread via Qt signals.

Only matplotlib functions may be run using this plan stub.

Parameters:
  • func – A matplotlib function reference.

  • *args – Arbitrary arguments, passed through to matplotlib.pyplot.subplots

  • **kwargs – Arbitrary keyword arguments, passed through to matplotlib.pyplot.subplots

Raises:

ValueError – if the passed function is not a matplotlib function.

Returns:

The return value of the wrapped function

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

Returns:

The return value of the wrapped function