我需要从其他异步函数调用的同步代码中调用异步代码
我尝试做Setting a descriptor in python3.5 asynchronously,但是这个答案对我没有帮助
async def first():
return second()
def second():
# TODO: In this function I want to call function thrird,
# and I want to call it asynchronous!
# This function MUST be syncronious (for example __get__)
async def third():
await asyncio.sleep(1)
async def main():
await asyncio.gather(
first(),
first()
)
# must work 1 second
asyncio.run(main())
此代码必须工作1秒,而不是2秒