]> git.llucax.com Git - software/pymin.git/blobdiff - pymin/procman.py
Bugfix: set the catched signal to None *after* calling the signal handler.
[software/pymin.git] / pymin / procman.py
index 0330e23542886dc0880e351f0538b01d88b4fe0a..4478cb7c0eff9b7280b1049162fea17e066ff0c6 100644 (file)
@@ -86,6 +86,15 @@ class ProcessManager:
         assert name in self.namemap
         self.namemap[name].stop()
 
         assert name in self.namemap
         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
         self.namemap[name].kill(name, stop)
     def kill(self, name, signum):
         assert name in self.namemap
         self.namemap[name].kill(name, stop)
@@ -131,7 +140,7 @@ class ProcessManager:
         else: # is a pid
             if name in self.pidmap:
                 return self.pidmap[name]
         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
 
     def has(self, name):
         if isinstance(name, basestring): # is a name
@@ -199,7 +208,7 @@ if __name__ == '__main__':
     while manager.pidmap:
         signal.pause()
         if sig == signal.SIGCHLD:
     while manager.pidmap:
         signal.pause()
         if sig == signal.SIGCHLD:
-            sig = None
             sigchild_handler(sig)
             sigchild_handler(sig)
+            sig = None
         print "Esperando...", [pi.name for pi in manager.namemap.values()]
 
         print "Esperando...", [pi.name for pi in manager.namemap.values()]