bluesky.plans.subs_wrapper

bluesky.plans.subs_wrapper(plan, subs)

Subscribe callbacks to the document stream; finally, unsubscribe.

Parameters:
  • plan (iterable or iterator) – a generator, list, or similar containing Msg objects
  • subs (callable, 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 confirm to f(name, doc) where name is one of {‘all’, ‘start’, ‘stop’, ‘event’, ‘descriptor’} and doc is a dictionary.

Yields:

msg (Msg) – messages from plan, with ‘subscribe’ and ‘unsubscribe’ messages inserted and appended