Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect against double subscription #77

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions nslsii/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ def configure_base(user_ns, broker_name, *,

>>>> configure_base(get_ipython().user_ns, 'chx');
"""
if configure_base.has_been_called:
raise RuntimeError(
"configure_base should only be called once per process.")
configure_base.has_been_called = True
ns = {} # We will update user_ns with this at the end.

# Set up a RunEngine and use metadata backed by a sqlite file.
Expand Down Expand Up @@ -206,6 +210,9 @@ def configure_base(user_ns, broker_name, *,
return list(ns)


configure_base.has_been_called = False


def configure_olog(user_ns, *, callback=None, subscribe=True):
"""
Setup a callback that publishes some metadata from the RunEngine to Olog.
Expand Down