编程

作者: asialine | 来源:发表于2017-12-01 11:47 被阅读0次

    ···python

    import asyncio

    import uvloop

    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

    @asyncio.coroutine

    def hello():

    print("Hello world!")

    # 异步调用asyncio.sleep(1):

    r = yield from asyncio.sleep(1)

    print("Hello again!")

    # 获取EventLoop:

    loop = asyncio.get_event_loop()

    # 执行coroutine

    loop.run_until_complete(hello())

    loop.close()

    ···

    相关文章

      网友评论

          本文标题:编程

          本文链接:https://www.haomeiwen.com/subject/aygibxtx.html