Open connection from FINESSE using "Manage devices" dialog
Close FTSW500 program window
Result:
A variety of uncaught exceptions
Workaround:
Don't do this :upside_down_face:. In the normal course of events, users shouldn't be closing FTSW500 while FINESSE is interacting with it, however we should handle this case cleanly, partly for UX reasons, but also for the sake of robustness: e.g. we don't want data recording to stop because a connection is lost to a device (not sure if that would actually happen here).
The most common error seems to be this:
Traceback (most recent call last):
File "/home/alex/code/FINESSE/finesse/hardware/plugins/spectrometer/ftsw500_interface.py", line 196, in _request_status
self.request_command(b"getFTSW500State\n")
File "/home/alex/code/FINESSE/finesse/hardware/plugins/spectrometer/ftsw500_interface.py", line 204, in request_command
self._make_request(command)
File "/home/alex/code/FINESSE/finesse/hardware/plugins/spectrometer/ftsw500_interface.py", line 191, in _make_request
self._requester.sendall(command)
BrokenPipeError: [Errno 32] Broken pipe
But I also sometimes see:
Traceback (most recent call last):
File "/home/alex/code/FINESSE/finesse/hardware/plugins/spectrometer/ftsw500_interface.py", line 196, in _request_status
self.request_command(b"getFTSW500State\n")
File "/home/alex/code/FINESSE/finesse/hardware/plugins/spectrometer/ftsw500_interface.py", line 204, in request_command
self._make_request(command)
File "/home/alex/code/FINESSE/finesse/hardware/plugins/spectrometer/ftsw500_interface.py", line 192, in _make_request
self._on_reply_received(self._requester.recv(1024))
File "/home/alex/code/FINESSE/finesse/hardware/plugins/spectrometer/ftsw500_interface.py", line 186, in _on_reply_received
self._regurgitate_nonmodal_dialog_message()
File "/home/alex/code/FINESSE/finesse/hardware/plugins/spectrometer/ftsw500_interface.py", line 147, in _regurgitate_nonmodal_dialog_message
if self._check_is_nonmodal_dialog_open():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/alex/code/FINESSE/finesse/hardware/plugins/spectrometer/ftsw500_interface.py", line 131, in _check_is_nonmodal_dialog_open
if data.decode().split("&")[1] == "true\n":
~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
BrokenPipeErrors should be caught with the error propagated to the fronted via a pubsub message (e.g. by using the pubsub_errors() decorator). In the second error I mention though, the code just needs to be written a bit more defensively. The send and receive operations for FTSW500Interfacecould possibly be encapsulated in their own functions with error handling taking place there (plus, having self._requester.recv(1024) dotted all over the place smells a bit wrong to me).
To reproduce:
Result:
Workaround:
The most common error seems to be this:
But I also sometimes see:
BrokenPipeError
s should be caught with the error propagated to the fronted via apubsub
message (e.g. by using thepubsub_errors()
decorator). In the second error I mention though, the code just needs to be written a bit more defensively. The send and receive operations forFTSW500Interface
could possibly be encapsulated in their own functions with error handling taking place there (plus, havingself._requester.recv(1024)
dotted all over the place smells a bit wrong to me).Tagging @dc2917