需要帮助自动化Python函数

时间:2017-06-15 16:05:09

标签: linux python-3.x enigma2

我这里有一个为Enigma 2 Linux机顶盒编写的python程序: VirtualZap Python program for Enigma 2 based set top boxes

我希望每分钟自动执行以下功能:

def aktualisieren(self):  
    self.updateInfos()

您可以在第436行和第437行找到已定义的函数。

我的问题是类VirtualZap只包含一个构造函数但没有实际程序运行的main方法,因此很难实现线程或协同程序。是否有可能自动执行aktualisieren函数?

1 个答案:

答案 0 :(得分:0)

有一个高级Python调度程序

from apscheduler.schedulers.blocking import BlockingScheduler

def aktualisieren(self):  
    self.updateInfos()

scheduler = BlockingScheduler()
scheduler.add_job(aktualisieren, 'interval', hours=1)
scheduler.start()