Skip to content

Commit

Permalink
Fix the bug that a normal websocket closing leaves an exception log (#…
Browse files Browse the repository at this point in the history
…280)

This resolved #279.
  • Loading branch information
BECATRUE authored Apr 5, 2024
2 parents 68635bf + ab84c7b commit a125d8d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions iquip/apps/dataviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from PyQt5.QtCore import (
pyqtSignal, pyqtSlot, QDate, QMutex, QObject, Qt, QThread, QWaitCondition
)
from websockets.exceptions import ConnectionClosedOK
from websockets.sync.client import connect, ClientConnection
from websockets.exceptions import ConnectionClosedOK, WebSocketException

import qiwis

Expand Down Expand Up @@ -899,7 +899,7 @@ def stop(self):
return
try:
self.websocket.close()
except WebSocketException:
except Exception: # pylint: disable=broad-exception-caught
logger.exception("Failed to stop fetching the dataset name list in ARTIQ master.")

def run(self):
Expand All @@ -913,6 +913,8 @@ def run(self):
if self.websocket.ping().wait(5):
continue
break # connection is lost
except ConnectionClosedOK:
return
self.fetched.emit(filter_dataset_list(json.loads(response)))
except Exception: # pylint: disable=broad-exception-caught
logger.exception("Failed to fetch the dataset name list.")
Expand Down Expand Up @@ -987,7 +989,7 @@ def stop(self):
"""Stops the thread."""
try:
self.websocket.close()
except WebSocketException:
except Exception: # pylint: disable=broad-exception-caught
logger.exception("Failed to stop synchronizing.")

def run(self):
Expand All @@ -1006,7 +1008,7 @@ def run(self):
self._initialize()
except ConnectionClosedOK:
self.stopped.emit("Stopped synchronizing.")
except WebSocketException:
except Exception: # pylint: disable=broad-exception-caught
msg = "Failed to synchronize the dataset."
self.stopped.emit(msg)
logger.exception(msg)
Expand Down
3 changes: 3 additions & 0 deletions iquip/apps/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
QCheckBox, QDoubleSpinBox, QGridLayout, QGroupBox, QHBoxLayout,
QLabel, QPushButton, QSlider, QVBoxLayout, QWidget
)
from websockets.exceptions import ConnectionClosedOK
from websockets.sync.client import connect

import qiwis
Expand Down Expand Up @@ -230,6 +231,8 @@ def run(self):
if websocket.ping().wait(5):
continue
break # connection is lost
except ConnectionClosedOK:
return
status = json.loads(response)
self.fetched.emit(status)
except Exception: # pylint: disable=broad-exception-caught
Expand Down
3 changes: 3 additions & 0 deletions iquip/apps/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
)
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtWidgets import QAction, QPushButton, QTableView, QVBoxLayout, QWidget
from websockets.exceptions import ConnectionClosedOK
from websockets.sync.client import connect

import qiwis
Expand Down Expand Up @@ -65,6 +66,8 @@ def run(self):
if websocket.ping().wait(5):
continue
break # connection is lost
except ConnectionClosedOK:
return
schedule = []
for rid, info in json.loads(response).items():
expid = info["expid"]
Expand Down

0 comments on commit a125d8d

Please sign in to comment.