async def worker(): with timeout(loop, 1): try: await asyncio.sleep(2) except asyncio.CancelledError: cleanup.set() raise
async def worker(): with timeout(loop, 1): try: await asyncio.sleep(2) except asyncio.CancelledError: # Swallow the exception pass ignored.set()
async def worker(): with timeout(loop, 2): raise Exception('inner')
async def worker(): with timeout(loop, 1): await asyncio.sleep(0.5)