Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I tried a different approach, and this seems to work (note I took out the daemon portions of the code as I didn't have that module installed).</p> <pre><code>import signal class Manager: """ This manager starts the http server processes and worker processes, creates the input/output queues that keep the processes work together nicely. """ def __init__(self): self.NUMBER_OF_PROCESSES = cpu_count() def start(self): # all your code minus the loop print "waiting to die" signal.pause() def stop(self): print "quitting ..." # all your code minus self.running manager = Manager() signal.signal(signal.SIGHUP, lambda signum, frame: manager.stop()) manager.start() </code></pre> <p>One warning, is that signal.pause() will unpause for any signal, so you may want to change your code accordingly.</p> <p><strong>EDIT:</strong></p> <p>The following works just fine for me:</p> <pre><code>import daemon import signal import time class Manager: """ This manager starts the http server processes and worker processes, creates the input/output queues that keep the processes work together nicely. """ def __init__(self): self.NUMBER_OF_PROCESSES = 5 def start(self): # all your code minus the loop print "waiting to die" self.running = 1 while self.running: time.sleep(1) print "quit" def stop(self): print "quitting ..." # all your code minus self.running self.running = 0 manager = Manager() context = daemon.DaemonContext() context.signal_map = {signal.SIGHUP : lambda signum, frame: manager.stop()} context.open() manager.start() </code></pre> <p>What version of python are you using?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload