| async def _timeout(ctx, ticks, domain = 'sync'):
await ctx.tick(domain).repeat(ticks)
raise TimeoutError()
@asynccontextmanager
async def timeout(ctx, ticks, domain = 'sync'):
async with ctx.group() as group:
group.start(_timeout(ctx, ticks, domain), background = True)
yield
async def testbench(ctx):
async with timeout(ctx, 100):
... # Some operation expected to take less than 100 ticks
async with timeout(ctx, 200):
... # Some other operation expected to take less than 200 ticks
|