Conversation
| try: | ||
| return self.ws.recv_nowait() | ||
| except WebSocketClosedError: | ||
| raise ConnectionClosedException() |
There was a problem hiding this comment.
This function will never raise a WebSocketClosedError
cylc-uiserver/cylc/uiserver/handlers.py
Lines 409 to 410 in ca46f5e
| async def send(self, data): | ||
| if self.ws.ws_connection and not self.ws.ws_connection.is_closing(): | ||
| await self.ws.write_message(data) | ||
| else: | ||
| raise WebSocketClosedError |
There was a problem hiding this comment.
Duplicates what self.ws.write_message(data) already does: https://github.com/tornadoweb/tornado/blob/fbc4b0332d068915e4b2593aea58d82532fac62c/tornado/websocket.py#L361-L365
Replaced this method with calling self.ws.write_message(data) directly
| async def close(self, code): | ||
| ws_close = self.ws.close(code) | ||
| if ws_close is not None: | ||
| await ws_close |
There was a problem hiding this comment.
self.ws.close() is not async and always returns None: https://github.com/tornadoweb/tornado/blob/fbc4b0332d068915e4b2593aea58d82532fac62c/tornado/websocket.py#L496
Replaced this method with calling self.ws.close() directly
| self.pending_tasks = WeakSet() | ||
| self.pending_tasks: set[asyncio.Task] = set() |
There was a problem hiding this comment.
Using a WeakSet does not prevent garbage collection of the pending tasks, so this wasn't really doing anything as far as I can tell
Precursor to addressing #690, tidy up some of this code
Check List
CONTRIBUTING.mdand added my name as a Code Contributor.