小编Vin*_*ent的帖子

如何使用Python安排一个不受系统时间变化影响的周期性任务

我正在使用python的sched模块定期运行一个任务,我想我遇到过一个bug.

我发现它依赖于运行python脚本的系统的时间.例如,假设我想每5秒运行一次任务.如果我转发系统时间,则计划任务将按预期运行.但是,如果我将系统时间倒回到1天,则下一个计划任务将在5秒+ 1天内运行.

如果您运行下面的脚本,然后几天前更改系统时间,那么您可以重现该问题.该问题可以在Linux和Windows上重现.

import sched
import time
import threading

period = 5
scheduler = sched.scheduler(time.time, time.sleep)

def check_scheduler():
    print time.time()
    scheduler.enter(period, 1, check_scheduler, ())

if __name__ == '__main__':
    print time.time()

    scheduler.enter(period, 1, check_scheduler, ())

    thread = threading.Thread(target=scheduler.run)
    thread.start()
    thread.join()
    exit(0)
Run Code Online (Sandbox Code Playgroud)

任何人都有这个问题的任何python解决方案?

python python-2.7

5
推荐指数
1
解决办法
148
查看次数

使用 Qt 安装程序框架脚本记录控制台输出

我通过组件/控制器脚本向我的安装程序添加了一些 console.log("xxxxxx")。

IE。

function Controller()
{
    console.log("OS: " + systemInfo.productType);
}
Run Code Online (Sandbox Code Playgroud)

如何在安装程序运行期间查看控制台日志?

qt qt-installer

5
推荐指数
1
解决办法
327
查看次数

标签 统计

python ×1

python-2.7 ×1

qt ×1

qt-installer ×1