Python 3.3.4: python-daemon-3K ; How to use runner -
struggling try , python daemon work using python 3.3.4. im using latest version of python-daemon-3k pypi i.e. 1.5.8
starting point following code found how create daemon in python? code believe 2.x python.
import time 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()
attempting run following error.
python mydaemon.py start
traceback (most recent call last): file "mydaemon.py", line 60, in daemon_runner = runner.daemonrunner(app) file "/depot/python-3.3.4/lib/python3.3/site-packages/python_daemon_3k-1.5.8-py3.3.egg/daemon/runner.py", line 89, in init app.stderr_path, 'w+', buffering=0) valueerror: can't have unbuffered text i/o
any pointer how translate work python 3.3.4 or example of using runner in python-daemon-3k
thanks derek
to make code run in python3 need make change in daemonrunner
class, cannot have unbuffered text io can have unbuffered bytes io changing mode to'wb+'
work:
class daemonrunner(object): self.parse_args() self.app = app self.daemon_context = daemoncontext() self.daemon_context.stdin = open(app.stdin_path, 'r') # linux /dev/tty must opened without buffering , b self.daemon_context.stdout = open(app.stdout_path, 'wb+',buffering=0) # w+ -> wb+ self.daemon_context.stderr = open( app.stderr_path, 'wb+', buffering=0)
Comments
Post a Comment