使用python:在x:00重复的间隔 [英] With python: intervals at x:00 repeat

查看:131
本文介绍了使用python:在x:00重复的间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何安排重复计时器间隔5分钟.哪个会在00秒时触发,然后在00时重复.好吧,这不是硬实时的,但与sys lags尽可能接近.试图避免滞后现象的积累并接近00.

How do I sched a repeat timer for 5 min intervals. Which fire at 00 seconds, then repeat at 00. Ok, not hard real-time but as close as possible with sys lags. Trying to avoid a build up in lags and get near 00.

Lang:Python,操作系统:WinXP x64

Lang: Python, OS: WinXP x64

系统具有25ms的分辨率.

System has 25ms resolution.

任何代码都会有用,tia

Any code would be helpful, tia

推荐答案

time.time测量确切时间并相应地更改下一个调度延迟来增加准确性.)

I don't know how to do it any more accurately than with threading.Timer. It's "one-shot", but that just means the function you schedule that way must immediately re-schedule itself for another 300 seconds later, first thing. (You can add accuracy by measuring the exact time with time.time each time and varying the next scheduling delay accordingly).

这篇关于使用python:在x:00重复的间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆