Skip to content

Commit c481e12

Browse files
Fix for Empty except
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 1a3aa67 commit c481e12

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎emulator/brainflow_emulator/biolistener_emulator.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ def run(self):
113113
# A failed connect may leave the socket unusable.
114114
try:
115115
self.server_socket.close()
116-
except Exception:
117-
pass
116+
except Exception as close_err:
117+
# Closing can fail if the socket is already invalid/closed after connect failure.
118+
# Ignore and continue with socket recreation.
119+
logging.debug(f"Ignoring socket close error during reconnect cleanup: {close_err}")
118120
# Recreate the socket with the same options.
119121
self.server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
120122
self.server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

0 commit comments

Comments
 (0)