Signals and Threads in Python 3.5 or so

Dan Stromberg drsalists at gmail.com
Sun Oct 9 19:52:05 EDT 2016


I have a program http://stromberg.dnsalias.org/~dstromberg/looper/
that I use and maintain.

It's like GNU parallel or similar - yet another "run n processes, m at
a time" implementation.  Interestingly, I've only used/tested it on
Linux, but it's under a Microsoft copyright because Microsoft acquired
a Linux company I was working for.

Anyway, it seems to work well, except one annoying bug.

That bug is: if you control-C the top-level process, all the
subprocesses are left running.

I've been thinking about making it catch SIGINT, SIGTERM and SIGHUP,
and having it SIGKILL its active subprocesses upon receiving one of
these signals.

However, it's multithreaded, and I've heard that in CPython, threads
and signals don't mix well.

Is this still an issue in CPython 3.5?  If yes, how can I work around it?

Thanks!



More information about the Python-list mailing list