예제 #1
0
async def nested_suspending(log):
    log(1)
    async with corocc.suspending():
        log(2)
        async with corocc.suspending():
            log(3)
        log(4)
    log(5)
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
async def cont_now(log):
    log(1)
    async with corocc.suspending() as cont:
        log(2)
        cont()
        log(3)
    log(4)
예제 #5
0
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
예제 #6
0
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)
예제 #7
0
async def cont_again_now_coro(log):
    log(1)
    async with corocc.suspending() as cont:
        log(2)
        cont()
        log(3)
        cont()
    log(4)
예제 #8
0
async def raise_later(log, save_cont):
    log(1)
    async with corocc.suspending() as cont:
        save_cont(cont)
    log(2)
    1/0
예제 #9
0
async def simple_coro(log):
    log(1)
    async with corocc.suspending() as cont:
        log(2)
        cont(3)
    log(cont.result)
예제 #10
0
async def unfinished_coro(log, save_cont):
    log(1)
    async with corocc.suspending() as cont:
        log(2)
        save_cont(cont)
    log(cont.result)
예제 #11
0
async def result_later(save_cont):
    async with corocc.suspending() as cont:
        save_cont(cont)
    return 42
예제 #12
0
async def background():
    async with corocc.suspending() as cont:
        threading.Thread(target=cont).start()