Is there a way to find out how often a coroutine has been suspended?
For example:
import trio
async def sleep(count: int):
for _ in range(count):
await trio.sleep(1)
async def test():
with track_suspensions() as ctx:
await sleep(1)
assert ctx.suspension_count == 1
with track_suspensions() as ctx:
await sleep(3)
assert ctx.suspension_count == 3
trio.run(test)
..except that (as far as I know), track_suspensions()
does not exist. Is the a way to implement it, or some other way to get this information? (I'm looking for this information to write a unit test).