FXIhub / hummingbird

Monitoring and Analysing flash X-ray imaging experiments
http://fxihub.github.io/hummingbird
BSD 2-Clause "Simplified" License
16 stars 14 forks source link

Cannot "Remove PlotData which is no longer in the conf" with python 3 #140

Closed andyofmelbourne closed 2 years ago

andyofmelbourne commented 2 years ago

In python 3 dict.keys() returns a view and not a copy of the keys, so you cannot pop items from the dictionary inside a loop over keys. The solution is to make a copy of the keys when iterating (python 2 and 3 safe).

Error:

Traceback (most recent call last):
  File "/home/andyofmelbourne/Documents/2022/Xavier_p003004/hummingbird/src/interface/data_source.py", line 183, in _get_request_reply
    for k in self._plotdata.keys():
RuntimeError: dictionary changed size during iteration

Solution:

#for k in self._plotdata.keys():
for k in list[self._plotdata.keys()]:
   if k not in self.titles:
      self._plotdata.pop(k)