From c481e1259ea41474c2b8abb63d6baddfd2163215 Mon Sep 17 00:00:00 2001 From: Andrey Parfenov Date: Sun, 26 Apr 2026 18:47:45 +0700 Subject: [PATCH] Fix for Empty except Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- emulator/brainflow_emulator/biolistener_emulator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/emulator/brainflow_emulator/biolistener_emulator.py b/emulator/brainflow_emulator/biolistener_emulator.py index 310744374..744a7f9fd 100755 --- a/emulator/brainflow_emulator/biolistener_emulator.py +++ b/emulator/brainflow_emulator/biolistener_emulator.py @@ -113,8 +113,10 @@ def run(self): # A failed connect may leave the socket unusable. try: self.server_socket.close() - except Exception: - pass + except Exception as close_err: + # Closing can fail if the socket is already invalid/closed after connect failure. + # Ignore and continue with socket recreation. + logging.debug(f"Ignoring socket close error during reconnect cleanup: {close_err}") # Recreate the socket with the same options. self.server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)