self.signal = None
self.process = None
self.error_count = 0
- self.last_return = None
self.running = False
def start(self):
assert self.process is None
self.kill(signal.SIGTERM)
def kill(self, signum):
assert self.process is not None
- os.kill(pi.process.pid, signum)
+ os.kill(self.process.pid, signum)
self.signal = signum
def __repr__(self):
pid = None
def stop(self, name):
assert name in self.namemap
- self.namemap[name].stop(name)
+ self.namemap[name].stop()
+
+ def restart(self, name):
+ logging.debug(u'ProcessManager.restart(%s)', name)
+ if name in self.namemap:
+ self.namemap[name].stop()
+ self.namemap[name].wait()
+ self.namemap[name].restart()
+ else:
+ self.namemap[name].start()
def kill(self, name, signum):
assert name in self.namemap
while pid:
if pid in self.pidmap:
p = self.pidmap[pid]
+ p.process.returncode = status
if p.callback is not None:
p.callback(self, p)
if p.dont_run or not p.persist or p.error_count >= p.max_errors:
else: # is a pid
if name in self.pidmap:
return self.pidmap[name]
- return KeyError, name
+ raise KeyError, name
def has(self, name):
if isinstance(name, basestring): # is a name
while manager.pidmap:
signal.pause()
if sig == signal.SIGCHLD:
- sig = None
sigchild_handler(sig)
+ sig = None
print "Esperando...", [pi.name for pi in manager.namemap.values()]