Skip to content

Commit

Permalink
Add logger to say how long a shard has been waiting for a semaphore
Browse files Browse the repository at this point in the history
  • Loading branch information
4Kaylum committed Jan 17, 2024
1 parent 4c45127 commit 9c6def8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions novus/api/gateway/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,20 @@ async def _connect(
ws_url = ws_url or self.ws_url
log.info("[%s] Creating websocket connection to %s", self.shard_id, ws_url)
try:
async def connection_timer(offset: int = 0) -> None:
try:
await asyncio.sleep(5)
except asyncio.CancelledError:
return
log.debug(
"[%s] Waited %s seconds at semaphore to connect to websocket",
self.shard_id, format(5 * (offset + 1), ","),
)
await connection_timer(offset + 1)
log_timer = asyncio.create_task(connection_timer())
async with self.connect_semaphore:
ws = await session.ws_connect(ws_url)
log_timer.cancel()
except Exception as e:
if attempt >= 5:
log.info(
Expand Down

0 comments on commit 9c6def8

Please sign in to comment.