bluesky.preprocessors.subs_wrapper

bluesky.preprocessors.subs_wrapper(plan, subs)[source]

Subscribe callbacks to the document stream; finally, unsubscribe.

Parameters
planiterable or iterator

a generator, list, or similar containing Msg objects

subscallable, list of callables, or dict of lists of callables

Documents of each type are routed to a list of functions. Input is normalized to a dict of lists of functions, like so:

None -> {‘all’: [], ‘start’: [], ‘stop’: [], ‘event’: [],

‘descriptor’: []}

func -> {‘all’: [func], ‘start’: [], ‘stop’: [], ‘event’: [],

‘descriptor’: []}

[f1, f2] -> {‘all’: [f1, f2], ‘start’: [], ‘stop’: [], ‘event’: [],

‘descriptor’: []}

{‘event’: [func]} -> {‘all’: [], ‘start’: [], ‘stop’: [],

‘event’: [func], ‘descriptor’: []}

Signature of functions must conform to f(name, doc) where name is one of {‘all’, ‘start’, ‘stop’, ‘event’, ‘descriptor’} and doc is a dictionary.

Yields
msgMsg

messages from plan, with ‘subscribe’ and ‘unsubscribe’ messages inserted and appended