Skip to content

Commit

Permalink
Add number of tasks in event loop to stats.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhsamuel committed Dec 15, 2024
1 parent 160d241 commit 7988f55
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/apsis/apsis.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,15 +610,18 @@ async def __check_async(self):
Monitors the async event loop.
"""
while True:
num_tasks = len(asyncio.all_tasks())

# Wake up on the next round 10 seconds.
t = now()
next_second = t.EPOCH + math.ceil((t - t.EPOCH + 0.01) / 10) * 10
await asyncio.sleep(next_second - t)

# See how late we are.
latency = now() - next_second

self.__check_async_stats = {
"latency": latency,
"latency" : latency,
"num_tasks" : num_tasks,
}


Expand Down

0 comments on commit 7988f55

Please sign in to comment.