| 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:
timeout_task = group.start(_timeout(ctx, ticks, domain))
yield
timeout_task.cancel()
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
|