Skip to content

Commit

Permalink
Don't respawn procs when the watcher is stopping.
Browse files Browse the repository at this point in the history
Fix #529
  • Loading branch information
almet committed Sep 12, 2013
1 parent 9a1d28a commit 3494841
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions circus/watcher.py
Expand Up @@ -182,6 +182,7 @@ def __init__(self, name, cmd, args=None, numprocesses=1, warmup_delay=0.,
self.args = args
self._process_counter = 0
self.stopped = stopped
self._stopping = False
self.graceful_timeout = float(graceful_timeout)
self.prereload_fn = prereload_fn
self.executable = None
Expand Down Expand Up @@ -434,7 +435,8 @@ def manage_processes(self):
self.kill_process(process)

# adding fresh processes
if self.respawn and len(self.processes) < self.numprocesses:
if (self.respawn and len(self.processes) < self.numprocesses
and not self._stopping):
self.spawn_processes()

# removing extra processes
Expand Down Expand Up @@ -561,7 +563,6 @@ def kill_process(self, process, sig=signal.SIGTERM):
self.send_signal(process.pid, sig)
self.notify_event("kill", {"process_pid": process.pid,
"time": time.time()})

except NoSuchProcess:
# already dead !
return
Expand Down Expand Up @@ -645,6 +646,8 @@ def stop(self, async=True, restarting=False):
for process in self.get_active_processes():
self.send_signal(process.pid, signal.SIGTERM)

self._stopping = True

# delayed SIGKILL if async is True
limit = time.time() + self.graceful_timeout

Expand Down Expand Up @@ -691,6 +694,7 @@ def _final_stop(self, limit=None, restarting=False, async=True):
self.notify_event("stop", {"time": time.time()})

self.stopped = True
self._stopping = False

# We ignore the hook result
self.call_hook('after_stop')
Expand Down

0 comments on commit 3494841

Please sign in to comment.