Python Asyncio

Summary

async def sleep(timeout):
    '''
    replacement asyncio.sleep function.
    it also exits when receiving globals.exitEvent event.
    '''
    print(f"sleep({timeout}) enter ... exitEvent={globals.exitEvent.is_set()}")
    try:
        await asyncio.wait_for( globals.exitEvent.wait(), timeout )
        print("sleep: got globals.exitEvent() quitting ...")
    except asyncio.TimeoutError:
        print(f"sleep({timeout}) except asyncio.TimeoutError - pass")
        pass
    return globals.exitEvent.is_set(

...

Python/AsyncIo (last edited 2019-08-06 04:36:41 by PieterSmit)