bluesky.preprocessors.contingency_wrapper#
- bluesky.preprocessors.contingency_wrapper(plan, *, except_plan=None, else_plan=None, final_plan=None, pause_for_debug=False, auto_raise=True)[source]#
try…except…else…finally helper
See
finalize_wrapper()
for a simplified but less powerful error-handling preprocessor.- Parameters:
- planiterable or iterator
a generator, list, or similar containing Msg objects
- except_plangenerator function, optional
This will be called with the exception as the only input. The plan does not need to re-raise, but may if you want to change the exception.
Only subclasses of Exception will be passed in, will not see GeneratorExit, SystemExit, or KeyboardInterrupt
- else_plangenerator function, optional
This will be called with no arguments if plan completes without raising
- final_plangenerator function, optional
a generator, list, or similar containing Msg objects or a callable that reurns one; attempted to be run no matter what happens in the first plan
- pause_for_debugbool, optional
If the plan should pause before running the clean final_plan in the case of an Exception. This is intended as a debugging tool only.
- auto_raisebool, optional
If the exception should be always be re-raised, reagardless of what except_plan does. Note this defaults to True for backwards compatibility, which is not the usual behaviour of an except statement
- Yields:
- msgMsg
messages from plan until it terminates or an error is raised, then messages from final_plan
See also