import asyncio

async def compute(x, y):
    print("Compute %s + %s ..." % (x, y))
    await asyncio.sleep(1.0)
    return x + y

async def print_sum(x, y):
    result = await compute(x, y)
    print("%s + %s = %s" % (x, y, result))

loop = asyncio.get_event_loop()
loop.run_until_complete(print_sum(1, 2))
loop.close()

 

 

python asyncio 协程调用task步骤

 

相关文章:

  • 2018-11-23
  • 2021-05-03
  • 2022-02-24
  • 2021-10-24
  • 2018-10-21
  • 2021-10-28
  • 2022-12-23
猜你喜欢
  • 2021-05-18
  • 2021-08-02
  • 2022-12-23
  • 2021-06-02
  • 2022-12-23
相关资源
相似解决方案