【发布时间】:2013-11-22 14:35:53
【问题描述】:
当代码在 Python 2.6 for Linux 中像守护进程一样工作时,我想每隔 x 秒重复一次函数。 我有一些代码,但它给我带来了很多问题。是否可以调用另一个file.py来代替在里面写代码?
代码如下:
import daemon
import threading
def hello():
print "hello, world"
t = threading.Timer(2.0, hello).start()
def run():
with daemon.DaemonContext():
hello()
if __name__ == "__main__":
run()
【问题讨论】:
-
您的问题可能已经在这里得到解答:stackoverflow.com/questions/2223157/…