如此死锁

await 不会沿用锁,要非常谨慎

import asyncio

lock = asyncio.Lock()

async def a():
    async with lock:
        await b()


async def b():
    async with lock:
        print(1)


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(a())

死锁!!

posted @ 2018-04-27 12:12  Inshua  阅读(160)  评论(0编辑  收藏  举报