bluesky.plan_stubs.call_in_thread#
- bluesky.plan_stubs.call_in_thread(func: ~collections.abc.Callable[[~P], ~bluesky.protocols.T], /, *args: ~typing.~P, **kwargs: ~typing.~P) Generator[Msg, Any, T][source]#
Call a blocking function in a worker thread and return its result.
Unlike calling
funcdirectly in a plan, this keeps the RunEngine’s event loop free whilefuncruns. An exception raised byfuncis raised in the plan.funcis called exactly once. If the plan is paused or suspended whilefuncruns,funckeeps running, and on resume the plan waits for it instead of calling it again. If the plan is aborted, stopped or halted,funcis not interrupted: it runs to completion in the background, and the Python process cannot exit until it returns. Give long-running functions their own timeout.funcruns outside the RunEngine’s message stream: devices it moves are not stopped on pause, abort or halt, statuses it creates are not tracked bywait, and values it reads are not recorded in documents.- Parameters:
- funccallable
blocking function to call
- args
passed to
func- kwargs
passed to
func
- Returns:
- result
the return value of
func. If no RunEngine runs the plan (for examplelist(plan)),funcis not called and this isNone.
- Yields:
- msgMsg
Msg('wait_for', ...). The RunEngine startsfuncthe first time it processes this message; if a pause interrupts the wait, the message is yielded again untilfuncreturns.