fix: ensure socket cleanup in websocket handler
This commit is contained in:
parent
bdc8f149dc
commit
70a405b231
@ -7,6 +7,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
## Version 1.7.0 - 2025-12-17
|
||||
|
||||
Fixes socket cleanup in the websocket handler to prevent resource leaks and improve connection stability.
|
||||
|
||||
**Changes:** 1 files, 29 lines
|
||||
**Languages:** Python (29 lines)
|
||||
|
||||
## Version 1.6.0 - 2025-12-17
|
||||
|
||||
Removes presence debounce to make user departures instant. Simplifies websocket connection and error handling in RPC views for improved reliability.
|
||||
|
||||
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "Snek"
|
||||
version = "1.6.0"
|
||||
version = "1.7.0"
|
||||
readme = "README.md"
|
||||
#license = { file = "LICENSE", content-type="text/markdown" }
|
||||
description = "Snek Chat Application by Molodetz"
|
||||
|
||||
@ -650,17 +650,20 @@ class RPCView(BaseView):
|
||||
)
|
||||
|
||||
rpc = RPCView.RPCApi(self, ws)
|
||||
async for msg in ws:
|
||||
if msg.type == web.WSMsgType.TEXT:
|
||||
try:
|
||||
await rpc(msg.json())
|
||||
except Exception as ex:
|
||||
print("XXXXXXXXXX Deleting socket", ex, flush=True)
|
||||
logger.exception(ex)
|
||||
await self.services.socket.delete(ws)
|
||||
break
|
||||
elif msg.type == web.WSMsgType.ERROR:
|
||||
pass
|
||||
elif msg.type == web.WSMsgType.CLOSE:
|
||||
pass
|
||||
try:
|
||||
async for msg in ws:
|
||||
if msg.type == web.WSMsgType.TEXT:
|
||||
try:
|
||||
await rpc(msg.json())
|
||||
except Exception as ex:
|
||||
print("XXXXXXXXXX Deleting socket", ex, flush=True)
|
||||
logger.exception(ex)
|
||||
await self.services.socket.delete(ws)
|
||||
break
|
||||
elif msg.type == web.WSMsgType.ERROR:
|
||||
pass
|
||||
elif msg.type == web.WSMsgType.CLOSE:
|
||||
pass
|
||||
finally:
|
||||
await self.services.socket.delete(ws)
|
||||
return ws
|
||||
|
||||
Loading…
Reference in New Issue
Block a user