mozilla-services/circus — pull request #634 by scottkmaxwell (2013-11-02 02:25:18+00:00)
Title: Fix _nextwid so that it handles graceful shutdown properly

If you have a watcher with numprocesses=1 and send_hup=false, a reload causes the next wid to be None. Next reload puts it back to 1. Then back to None, etc.

The reason is that the _nextwid property is trying to find an available slot. Since graceful reload starts a new process first, then kills the old, the slots are all full. So _nextwid simply finishes, implicitly returning None.

What is worse, _nextwid would actual raise a RuntimeError if numprocesses > 1 and you try to do a graceful reload.

I rewrote the mechanism to use set unions. I made all_wids be numprocesses * 2 to handle the graceful reload case.