Note that there are some explanatory texts on larger screens.

plurals
  1. POCatching signals sent by runit (sv stop <id>)
    text
    copied!<p>I have a python program that is running a number of worker processes. Because this has to be handled properly to avoid orphaned processes, I have implemented a signal handler to shutdown all worker processes.</p> <p>The program starts more or less like this:</p> <ol> <li>Start process pool (starts X number of workers)</li> <li>Register signal handlers (<code>signal.signal(signal.SIGTERM, my_signal_handler)</code>). I also add another signal handler for <code>SIGINT</code> with the same handler.</li> <li>Start seperate thread polling backend (database) and add the tasks to process pool.</li> <li>On main thread, poll process pool for results (there is a result <code>multiprocessing.Queue</code> that the individual workers add the results to).</li> </ol> <p>The idea is that the two seperate threads started in 3 and 4 keep the tasks running through the machinery.</p> <p>If I start this manually and call <code>kill -15 &lt;pid&gt;</code> or <code>kill -2 &lt;pid&gt;</code> it correctly shuts everything down, waits for processes to <code>join()</code>. Reading from the documentation, runit sends a <code>TERM</code> to the process, followed by <code>CONT</code>. However, running this under runit, it simply shows the standard <code>ok: down: &lt;my_program&gt;: 1s, normally up</code>, but the process is still running in the background (even the main process, it is UNTOUCHED).</p> <p>If I then afterwards go out and manually kill the process, I can see in the log file that it shuts down correctly. What am I doing wrong? It seems that runit ONLY kills the 3-line shell script I created to activate the virtualenv, but leaves the actual python process behind.</p> <p>Even if I run the "run" script directly, I can either run <code>kill</code> or Ctrl+C (same as <code>SIGINT</code>) and it shuts down correctly.</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