Skip to content

Commit

Permalink
Avoid ResourceWarning if shutdown failed for some reason (#272)
Browse files Browse the repository at this point in the history
* Avoiding ResourceWarning if shutdown failed for some reason.
Typically it looks like this:
/home/user/.local/lib/python3.8/site-packages/ws4py/websocket.py:230: ResourceWarning: unclosed <ssl.SSLSocket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.200.11.18', 40248)>

* Update ws4py/websocket.py

Signed-off-by: Asif Saif Uddin <[email protected]>

---------

Signed-off-by: Asif Saif Uddin <[email protected]>
Co-authored-by: Vasily Zakharov <[email protected]>
Co-authored-by: Asif Saif Uddin <[email protected]>
  • Loading branch information
3 people authored Dec 24, 2024
1 parent 3c3cc34 commit 4989bb7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ws4py/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,14 @@ def close_connection(self):
if self.sock:
try:
self.sock.shutdown(socket.SHUT_RDWR)
except:
pass
try:
self.sock.close()
except:
pass
finally:
self.sock = None
self.sock = None


def ping(self, message):
"""
Expand Down

0 comments on commit 4989bb7

Please sign in to comment.