Skip to content

Commit a6211d5

Browse files
author
nbdy
committed
Improve exception handling in close method:
- Replace `ValueError` with `Exception` to handle broader cleanup errors. - Suppress potential issues during stream and socket closure consistently.
1 parent d705efe commit a6211d5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

pygpsd/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def poll(self) -> Data:
109109

110110
return Data.from_json(msg)
111111

112+
# noinspection PyBroadException
112113
def close(self) -> None:
113114
"""
114115
Close the connection to the GPS daemon and release resources.
@@ -118,13 +119,13 @@ def close(self) -> None:
118119
if self.stream:
119120
try:
120121
self.stream.close()
121-
except ValueError:
122+
except Exception:
122123
pass # Ignore errors during cleanup
123124
self.stream = None
124125
if self.socket:
125126
try:
126127
self.socket.close()
127-
except ValueError:
128+
except Exception:
128129
pass # Ignore errors during cleanup
129130

130131
def __enter__(self) -> "GPSD":

0 commit comments

Comments
 (0)