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())

死锁!!

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2021-11-22
  • 2021-10-27
  • 2021-11-13
猜你喜欢
  • 2021-08-14
  • 2021-12-31
  • 2022-12-23
  • 2021-09-12
  • 2021-08-29
  • 2021-06-28
  • 2021-05-15
相关资源
相似解决方案