From fbe65e123a74a532d8e603831cf35d58b9a9e03e Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Wed, 21 May 2008 13:40:59 -0300 Subject: [PATCH] Make procman.ProcessManager return True is an action could be taken (refs #11). For start(), stop(), restart() and kill(), return True if the action could be taken. That is True if the process wasn't already running for start(), and for stop(), restart() and kill(), True if the process was already running. --- pymin/procman.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pymin/procman.py b/pymin/procman.py index 0d67b9b..0bfb721 100644 --- a/pymin/procman.py +++ b/pymin/procman.py @@ -110,13 +110,17 @@ class ProcessManager: def start(self, name): log.debug(u'ProcessManager.start(%s)', name) - assert name not in self.namemap - self._call(self.services[name]) + if name not in self.namemap: + self._call(self.services[name]) + return True + return False def stop(self, name): log.debug(u'ProcessManager.stop(%s)', name) - assert name in self.namemap - self.namemap[name].stop() + if name in self.namemap: + self.namemap[name].stop() + return True + return False def restart(self, name): log.debug(u'ProcessManager.restart(%s)', name) @@ -131,13 +135,17 @@ class ProcessManager: pi.restart() # add the new PID self.pidmap[pi.process.pid] = pi + return True else: self.start(name) + return False def kill(self, name, signum): log.debug(u'ProcessManager.kill(%s, %s)', name, signum) - assert name in self.namemap - self.namemap[name].kill(name, stop) + if name in self.namemap: + self.namemap[name].kill(name, stop) + return True + return False def sigchild_handler(self, signum, stack_frame=None): log.debug(u'ProcessManager.sigchild_handler(%s)', signum) -- 2.43.0