Skip to content

Commit 4a2a583

Browse files
committed
Ensures the connection is closed when the object is garbage collected.
1 parent 6304d10 commit 4a2a583

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/websockets/sync/connection.py

+3
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ def __exit__(
226226
else:
227227
self.close(CloseCode.INTERNAL_ERROR)
228228

229+
def __del__(self) -> None:
230+
self.close()
231+
229232
def __iter__(self) -> Iterator[Data]:
230233
"""
231234
Iterate on incoming messages.

0 commit comments

Comments
 (0)