bluesky_tiled_plugins.writing._dispatcher#

This module vendors the Dispatcher from bluesky.run_engine, in order to avoid a bluesky dependency, since bluesky-tiled-plugins is frequently used in data analysis environments where a bluesky dependency would be superfluous.

This dispatcher could in the future be move upstream to event_model where it could be shared by bluesky and bluesky-tiled-plugins.

That code has been extremely stable for about ten years, so divergence is not a pressing concern.

Module Contents#

Classes#

Dispatcher

Dispatch documents to user-defined consumers on the main thread.

CallbackRegistry

See matplotlib.cbook.CallbackRegistry. This is a simplified since bluesky is python3.4+ only!

API#

class bluesky_tiled_plugins.writing._dispatcher.Dispatcher#

Dispatch documents to user-defined consumers on the main thread.

process(name, doc)#

Dispatch document doc of type name to the callback registry.

Parameters

name : {‘start’, ‘descriptor’, ‘event’, ‘stop’} doc : dict

subscribe(func, name='all')#

Register a callback function to consume documents.

.. versionchanged :: 0.10.0 The order of the arguments was swapped and the name argument has been given a default value, 'all'. Because the meaning of the arguments is unambiguous (they must be a callable and a string, respectively) the old order will be supported indefinitely, with a warning.

.. versionchanged :: 0.10.0 The order of the arguments was swapped and the name argument has been given a default value, 'all'. Because the meaning of the arguments is unambiguous (they must be a callable and a string, respectively) the old order will be supported indefinitely, with a warning.

Parameters

func: callable expecting signature like f(name, document) where name is a string and document is a dict name : {‘all’, ‘start’, ‘descriptor’, ‘event’, ‘stop’}, optional the type of document this function should receive (‘all’ by default).

Returns

token : int an integer ID that can be used to unsubscribe

See Also

:meth:Dispatcher.unsubscribe an integer token that can be used to unsubscribe

unsubscribe(token)#

Unregister a callback function using its integer ID.

Parameters

token : int the integer ID issued by :meth:Dispatcher.subscribe

See Also

:meth:Dispatcher.subscribe

unsubscribe_all()#

Unregister all callbacks from the dispatcher.

property ignore_exceptions#
class bluesky_tiled_plugins.writing._dispatcher.CallbackRegistry(ignore_exceptions=False, allowed_sigs=None)#

See matplotlib.cbook.CallbackRegistry. This is a simplified since bluesky is python3.4+ only!

connect(sig, func)#

Register func to be called when sig is generated

Parameters

sig func

Returns

cid : int The callback index. To be used with disconnect to deregister func so that it will no longer be called when sig is generated

disconnect(cid)#

Disconnect the callback registered with callback id cid

Parameters

cid : int The callback index and return value from connect

process(sig, *args, **kwargs)#

Process sig

All of the functions registered to receive callbacks on sig will be called with args and kwargs

Parameters

sig args kwargs