Python-延迟后运行异步函数,不阻塞其他代码

Python-延迟后运行异步函数,不阻塞其他代码,python,asynchronous,timer,python-asyncio,Python,Asynchronous,Timer,Python Asyncio,这是我的密码: async def outer(): # if this while loop was not broken in 5 seconds, do something while True: # some code with breaks 通常我需要一个非阻塞异步计时器。def outer(): 异步定义循环(): #在这里循环 task=asyncio.create_任务(loop()) 完成,挂起=wait asyncio.wait([

这是我的密码:

async def outer():
    # if this while loop was not broken in 5 seconds, do something
    while True:
        # some code with breaks
    
通常我需要一个非阻塞异步计时器。

def outer():
异步定义循环():
#在这里循环
task=asyncio.create_任务(loop())
完成,挂起=wait asyncio.wait([task],在=asyncio.FIRST\u完成时返回,超时=5)
如果任务已完成:
#循环已完成
其他:
#循环不完整
参考资料:

asyncio.sleep
?@python\u用户不,它会在同一个函数中阻止其他代码。你的意思是如果
outer
没有在5秒内完成,你需要做点什么吗?@Ceres不,我需要检查while的完成时间