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#
Dispatch documents to user-defined consumers on the main thread. |
|
See matplotlib.cbook.CallbackRegistry. This is a simplified since
|
API#
- class bluesky_tiled_plugins.writing._dispatcher.Dispatcher#
Dispatch documents to user-defined consumers on the main thread.
- process(name, doc)#
Dispatch document
docof typenameto 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
nameargument 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
nameargument 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.unsubscribean 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.subscribeSee 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
blueskyis python3.4+ only!- connect(sig, func)#
Register
functo be called whensigis generatedParameters
sig func
Returns
cid : int The callback index. To be used with
disconnectto deregisterfuncso that it will no longer be called whensigis 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
sigAll of the functions registered to receive callbacks on
sigwill be called withargsandkwargsParameters
sig args kwargs