cms
cms copied to clipboard
Make the Worker Python process kill the actual worker thread when exiting
At the moment when the Worker (i.e. the cmsWorker process) is killed (by Ctrl+C, by RS, etc.), the actual working (where compilation and evaluation happen) thread could remain alive. This needs to be fixed.
Being an ignorant in multi-thread programming in Python, I suggest to see if the daemon=True argument to Thread.__init__ is enough.
Is this the point where the Thread is created? https://github.com/cms-dev/cms/blob/master/cms/async/AsyncLibrary.py#L447
It should.
Anyway, I think that for some reason the fix is not as simple as using daemon, otherwise I would already done it at the time. I remember that I looked a bit at this issue, but later gave up. I don't remember the details.
BTW, this issue was automatically solved when passing to gevent. However, the Worker still doesn't kill its children (sandboxes, programs being evaluated, ...) when being shut down.
This isn't ususally a problem, since most tasks allow at most a few seconds for evaluated programs. Yet, it would be nice to be sure that no junk is left over.