【发布时间】:2015-02-14 20:24:17
【问题描述】:
努力尝试让 python 守护程序使用 Python 3.3.4 工作。我使用来自 PyPi 的最新版本的 python-daemon-3K,即 1.5.8
起点是以下代码找到How do you create a daemon in Python? 代码我相信是2.x Python。
import time
from daemon import runner
class App():
def __init__(self):
self.stdin_path = '/dev/null'
self.stdout_path = '/dev/tty'
self.stderr_path = '/dev/tty'
self.pidfile_path = '/tmp/foo.pid'
self.pidfile_timeout = 5
def run(self):
while True:
print("Howdy! Gig'em! Whoop!")
time.sleep(10)
app = App()
daemon_runner = runner.DaemonRunner(app)
daemon_runner.do_action()
尝试运行时出现以下错误。
python mydaemon.py 启动
回溯(最近一次通话最后): 文件“mydaemon.py”,第 60 行,在 daemon_runner = runner.DaemonRunner(app) 文件“/depot/Python-3.3.4/lib/python3.3/site-packages/python_daemon_3K-1.5.8-py3.3.egg/daemon/runner.py”,第 89 行,在 init强> app.stderr_path, 'w+', 缓冲=0) ValueError: can't have unbuffered text I/O
任何指针如何转换为使用 Python 3.3.4 或在 python-daemon-3K 中使用运行器的一个很好的例子
谢谢 德里克
【问题讨论】:
标签: python daemon python-daemon