async def nested_suspending(log): log(1) async with corocc.suspending(): log(2) async with corocc.suspending(): log(3) log(4) log(5)
async def different_cont_again_coro(log): log(1) async with corocc.suspending() as cont1: log(2) cont1() # first call, ok async with corocc.suspending() as cont2: log(3) cont1() # calling cont1() again, must raise log(4)
async def cont_again_coro(log, save_cont): log(1) async with corocc.suspending() as cont: log(2) save_cont(cont) log(3) log(4)
async def cont_now(log): log(1) async with corocc.suspending() as cont: log(2) cont() log(3) log(4)
async def future_finish_later(log): log(1) async with corocc.suspending() as cont: # continue execution in a different thread threading.Timer(0.01, cont).start() log(2) return 42
async def send_exc_coro(log, save_cont): log(1) try: async with corocc.suspending() as cont: log(2) save_cont(cont) log(3) except ZeroDivisionError: log(4) except: log(5) else: log(6) log(7) async with corocc.suspending() as cont: save_cont(cont) log(8)
async def cont_again_now_coro(log): log(1) async with corocc.suspending() as cont: log(2) cont() log(3) cont() log(4)
async def raise_later(log, save_cont): log(1) async with corocc.suspending() as cont: save_cont(cont) log(2) 1/0
async def simple_coro(log): log(1) async with corocc.suspending() as cont: log(2) cont(3) log(cont.result)
async def unfinished_coro(log, save_cont): log(1) async with corocc.suspending() as cont: log(2) save_cont(cont) log(cont.result)
async def result_later(save_cont): async with corocc.suspending() as cont: save_cont(cont) return 42
async def background(): async with corocc.suspending() as cont: threading.Thread(target=cont).start()