BCDA-APS / use_bluesky

Tools to help APS use the Bluesky Framework (https://blueskyproject.io/)
8 stars 3 forks source link

RuntimeError: This event loop is already running #37

Closed prjemian closed 5 years ago

prjemian commented 5 years ago

This persistent exception is raised when submitting bp.count() to the RE. What's up? (In a jupyter notebook):

RuntimeError: This event loop is already running

Notebook starts with this:

%matplotlib notebook
from bluesky.utils import install_qt_kicker
install_qt_kicker()

from bluesky import RunEngine
import bluesky.plans as bp

RE = RunEngine({})

from ophyd.sim import hw
sim = hw()

Next block raise the exception:

RE(bp.count([sim.det], num=3), print)

Full trace, as shown:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-2-448bacda46ce> in <module>
----> 1 RE(bp.count([sim.det], num=3), print)

~/Apps/BlueSky/lib/python3.6/site-packages/bluesky/run_engine.py in __call__(self, *args, **metadata_kw)
    743             self.log.info("Executing plan %r", self._plan)
    744             try:
--> 745                 self.loop.run_forever()
    746             finally:
    747                 if self._task.done():

~/Apps/BlueSky/lib/python3.6/asyncio/base_events.py in run_forever(self)
    407         self._check_closed()
    408         if self.is_running():
--> 409             raise RuntimeError('This event loop is already running')
    410         if events._get_running_loop() is not None:
    411             raise RuntimeError(

RuntimeError: This event loop is already running

start {'uid': '43b62cc8-9720-4cdb-a3ef-0cbfebbc7e92', 'time': 1552075145.1420803, 'hints': {'dimensions': [(('time',), 'primary')]}, 'detectors': ['det'], 'scan_id': 1, 'plan_type': 'generator', 'plan_name': 'count', 'plan_args': {'detectors': ["SynGauss(name='det', value=1.0, timestamp=1552075141.1538517)"], 'num': 3}, 'num_points': 3, 'num_intervals': 2}
descriptor {'run_start': '43b62cc8-9720-4cdb-a3ef-0cbfebbc7e92', 'time': 1552075145.1602635, 'data_keys': {'det': {'source': 'SIM:det', 'dtype': 'number', 'shape': [], 'precision': 3, 'object_name': 'det'}}, 'uid': '0bf743e3-f342-407d-b7e4-cb36f72688e2', 'configuration': {'det': {'data': {'det': 1.0}, 'timestamps': {'det': 1552075145.1559622}, 'data_keys': {'det': {'source': 'SIM:det', 'dtype': 'number', 'shape': [], 'precision': 3}}}}, 'name': 'primary', 'hints': {'det': {'fields': []}}, 'object_keys': {'det': ['det']}}
event {'descriptor': '0bf743e3-f342-407d-b7e4-cb36f72688e2', 'time': 1552075145.1743572, 'data': {'det': 1.0}, 'timestamps': {'det': 1552075145.1559622}, 'seq_num': 1, 'uid': 'a3d3e057-b4ed-4fbc-ac57-f851b64de46c', 'filled': {}}
event {'descriptor': '0bf743e3-f342-407d-b7e4-cb36f72688e2', 'time': 1552075145.1840065, 'data': {'det': 1.0}, 'timestamps': {'det': 1552075145.183355}, 'seq_num': 2, 'uid': 'bfabedb0-d87c-4780-8ac2-c98de4761890', 'filled': {}}
event {'descriptor': '0bf743e3-f342-407d-b7e4-cb36f72688e2', 'time': 1552075145.193454, 'data': {'det': 1.0}, 'timestamps': {'det': 1552075145.192646}, 'seq_num': 3, 'uid': '4b4df5e1-0779-4d8b-b677-dca6ab393447', 'filled': {}}
stop {'run_start': '43b62cc8-9720-4cdb-a3ef-0cbfebbc7e92', 'time': 1552075145.2001033, 'uid': '10a5d9cb-74fd-41ca-8e7c-e58373aa315f', 'exit_status': 'success', 'reason': '', 'num_events': {'primary': 3}}
prjemian commented 5 years ago

This comes from using the tornado package version >=5. Need to pin (create/edit file <env>/conda-meta/pinned) with text tornado<5 and downgrade tornado (in the bluesky environment) with conda install -n bluesky tornado=4