Skip to content

Commit f850f53

Browse files
committed
Add username to logging of ws fails
1 parent a49c46f commit f850f53

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bases/rsptx/book_server_api/routers/discuss.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ async def connect(self, user: str, websocket: WebSocket):
8484
self.active_connections[user] = websocket
8585

8686
def disconnect(self, sockid: str):
87-
del self.active_connections[sockid]
87+
if sockid in self.active_connections:
88+
del self.active_connections[sockid]
8889

8990
async def send_personal_message(
9091
self,
@@ -186,14 +187,14 @@ async def my_get_message():
186187
psfail, wsfail = failures
187188

188189
if wsfail is not None:
189-
rslogger.info(f"PEERCOMM websocket fail {wsfail}")
190+
rslogger.info(f"PEERCOMM websocket fail {wsfail} for {username}")
190191
# The fail is more than likely a runtime error from a page close or refresh
191192
# RuntimeError('Cannot call "receive" once a disconnect message has been received.')
192193
manager.disconnect(username)
193194
return
194195

195196
if psfail is not None:
196-
rslogger.error(f"PEERCOM pubsub fail {psfail}")
197+
rslogger.error(f"PEERCOM pubsub fail {psfail} for {username}")
197198
# probably do not want to return
198199

199200
# handle message from the pubsub queue

0 commit comments

Comments
 (0)