Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Worker issue
from circuits.app import daemon
from circuits import Manager, Worker, Debugger, Component, task
import sys
import logging
manager = Manager()
handler = logging.FileHandler('debug.log')
logger = logging.getLogger('test_log')
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
isDaemonized = not '--no-daemon' in sys.argv
class TestComponent(Component):
def test_function(self):
with open('result', 'a') as f:
if isDaemonized:
f.write('Write daemonized\n')
else:
f.write('Write not daemonized\n')
return "success"
def started(self, component):
print( (yield self.call(task(self.test_function), 'worker')))
Debugger(logger=logger).register(manager)
if isDaemonized:
daemon.Daemon('test.pid', path='/tmp').register(manager)
Worker().register(manager)
TestComponent().register(manager)
manager.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment