fix(plugin): a try catch for webscoket send
This commit is contained in:
parent
5b2cb407c7
commit
0dec0015a5
@ -132,13 +132,18 @@ async def websocket_handler(request):
|
||||
return ws
|
||||
|
||||
async def send(event, data, sid=None):
|
||||
try:
|
||||
if sid:
|
||||
ws = sockets.get(sid)
|
||||
if ws:
|
||||
if ws and not ws.closed: # Check if the WebSocket connection is open and not closing
|
||||
await ws.send_json({ 'event': event, 'data': data })
|
||||
else:
|
||||
for ws in sockets.values():
|
||||
if not ws.closed: # Check if the WebSocket connection is open and not closing
|
||||
await ws.send_json({ 'event': event, 'data': data })
|
||||
except Exception as e:
|
||||
print(f"Exception: {e}")
|
||||
traceback.print_exc()
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user