










import asyncio
import time
async def my_coroutine():
await asyncio.sleep(1)
print("Coroutine executed!")
s = time.perf_counter()
loop = asyncio.get_event_loop()
loop.create_task(my_coroutine())
asyncio.run_coroutine_threadsafe(my_coroutine(), loop)
asyncio.gather(my_coroutine())
elapsed = time.perf_counter() - s
print(f"Script executed in {elapsed:0.2f} seconds.")
async def main():
print(1)
await main()
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。