asyncio async使用

2018-07-01  本文已影响0人  Do_More
import time
import asyncio

now = lambda : time.time()

async def do_some_work(x):
    print('Waiting: ', x)

start = now()
coroutine = do_some_work(2)
loop = asyncio.get_event_loop()

loop.run_until_complete(coroutine)

print('time: ', now() - start)
上一篇下一篇

猜你喜欢

热点阅读