Skip to content

Commit

Permalink
[replit_river] close websocket right away whe closing
Browse files Browse the repository at this point in the history
Why
===
* We were seeing lots of log spam at the end of test runs starting
with

> Task was destroyed but it is pending!

What changed
===
* Instead of enqueuing a websocket close task while closing the
websocket wrapper, immediately close the websocket

Test plan
===
* Run any e2e test in ai with this new version and see there is no
longer a bunch of log spam
  • Loading branch information
ryantm committed Oct 10, 2024
1 parent 80e6d95 commit 67ce0b3
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions replit_river/websocket_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,5 @@ async def close(self) -> None:
async with self.ws_lock:
if self.ws_state == WsState.OPEN:
self.ws_state = WsState.CLOSING
task = asyncio.create_task(self.ws.close())
task.add_done_callback(
lambda _: logger.debug("old websocket %s closed.", self.ws.id)
)
await self.ws.close()
self.ws_state = WsState.CLOSED

0 comments on commit 67ce0b3

Please sign in to comment.