2024-10-02 08:30:50 发布
网友
如果Ischedule a callback using ^{}(或使用loop.call_at(),其行为方式相同),是否可以取消其执行
loop.call_at()
为什么??比如说,我计划从现在开始一分钟后运行一些东西。但是,由于某些条件,代码决定中止该执行(因为不再需要它),或者决定将其重新安排到另一个时间。问题是如何使用Python的asyncio实现它
asyncio
如果您熟悉JavaScript,我正在寻找setTimeout()和clearTimeout()的等价物
setTimeout()
clearTimeout()
从链接的docs中:
An instance of asyncio.TimerHandle is returned which can be used to cancel the callback.
asyncio.TimerHandle
从{}的{a2}开始,一个{}的超类:
cancel()Cancel the callback. If the callback has already been canceled or executed, this method has no effect.
cancel()
Cancel the callback. If the callback has already been canceled or executed, this method has no effect.
所以只需调用句柄的cancel方法
cancel
从链接的docs中:
从{}的{a2}开始,一个{}的超类:
所以只需调用句柄的
cancel
方法相关问题 更多 >
编程相关推荐