timeflux / timeflux_ui

Timeflux web app engine
MIT License
11 stars 4 forks source link

Crash due to runtime error on UI #4

Closed dojeda closed 5 years ago

dojeda commented 5 years ago

I got this bug while doing some benchmark acquisitions:

2019-09-19 15:34:49,982 INFO       timeflux     8816     MainProcess      Timeflux 0+unknown
2019-09-19 15:34:49,986 DEBUG      manager      8816     MainProcess      Importing C:\Users\Vivatech\benchmark\graphs\common.yaml
2019-09-19 15:34:50,000 DEBUG      manager      8816     MainProcess      Importing C:\Users\Vivatech\benchmark\graphs\nexus.yaml
2019-09-19 15:34:50,005 DEBUG      manager      8816     MainProcess      Importing C:\Users\Vivatech\benchmark\graphs\bitalino.yaml
2019-09-19 15:34:50,023 DEBUG      manager      8816     MainProcess      Worker spawned with PID 15216
2019-09-19 15:34:50,030 DEBUG      manager      8816     MainProcess      Worker spawned with PID 7172
2019-09-19 15:34:50,037 DEBUG      manager      8816     MainProcess      Worker spawned with PID 2008
2019-09-19 15:34:50,044 DEBUG      manager      8816     MainProcess      Worker spawned with PID 13624
2019-09-19 15:34:50,052 DEBUG      manager      8816     MainProcess      Worker spawned with PID 4908
2019-09-19 15:34:51,667 INFO       ui           7172     ui_and_save      UI available at http://localhost:8000
2019-09-19 15:34:51,670 INFO       hdf5         7172     ui_and_save      Saving to data\20190919-153451.hdf5
2019-09-19 15:34:53,703 INFO       driver       4908     bitalino         BITalino_v5.1
2019-09-19 15:34:53,835 INFO       driver       4908     bitalino         Battery: 78.52%
2019-09-19 15:35:00,431 DEBUG      ui           7172     ui_and_save      Connect: e5a796c2-d446-4c78-a957-dc3fd10e605b
2019-09-19 15:35:00,466 DEBUG      ui           7172     ui_and_save      Connect: 32921e2b-cb76-4931-a4ee-66b858266965
2019-09-19 15:35:06,712 DEBUG      ui           7172     ui_and_save      Subscribe: e5a796c2-d446-4c78-a957-dc3fd10e605b to nexus
2019-09-19 15:35:48,936 DEBUG      ui           7172     ui_and_save      Subscribe: e5a796c2-d446-4c78-a957-dc3fd10e605b to bitalino
2019-09-19 15:36:06,887 DEBUG      ui           7172     ui_and_save      Unsubscribe: e5a796c2-d446-4c78-a957-dc3fd10e605b from nexus
2019-09-19 15:36:06,887 DEBUG      ui           7172     ui_and_save      Unsubscribe: e5a796c2-d446-4c78-a957-dc3fd10e605b from bitalino
2019-09-19 15:36:06,887 DEBUG      ui           7172     ui_and_save      Disconnect: e5a796c2-d446-4c78-a957-dc3fd10e605b
2019-09-19 15:36:38,073 ERROR      worker       7172     ui_and_save      dictionary changed size during iteration
Traceback (most recent call last):
  File "d:\programmes\anaconda3\envs\benchmark-env\lib\site-packages\timeflux\core\worker.py", line 59, in _run
    scheduler.run()
  File "d:\programmes\anaconda3\envs\benchmark-env\lib\site-packages\timeflux\core\scheduler.py", line 22, in run
    self.next()
  File "d:\programmes\anaconda3\envs\benchmark-env\lib\site-packages\timeflux\core\scheduler.py", line 52, in next
    self._nodes[step['node']].update()
  File "d:\programmes\anaconda3\envs\benchmark-env\lib\site-packages\timeflux_ui\nodes\ui.py", line 288, in update
    for name in self._buffer.keys():
RuntimeError: dictionary changed size during iteration
2019-09-19 15:36:38,400 INFO       worker       7172     ui_and_save      Terminating

I cannot describe exactly how I generated this error. On my protocol, I use timeflux_ui to quickly assess that the signals look good. In this particular case, I remember that I accidentally shows all signals (with append) for a Nexus node, then removed one, to then add all the signals (with append again) of a BITalino node.

This occured with timeflux_ui at c1efe65

mesca commented 5 years ago

Looks like a race condition on a call that is not thread-safe. Will fix ASAP.