]> git.llucax.com Git - software/pymin.git/commitdiff
Make some procman.ProcessManager's methods return the ProcessInfo instance.
authorLeandro Lucarella <llucax@gmail.com>
Tue, 20 May 2008 02:21:00 +0000 (23:21 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Wed, 21 May 2008 16:01:57 +0000 (13:01 -0300)
Now registar(), unregister() and once() procman.ProcessManager's methods
returns the ProcessInfo instance just created/removed.

pymin/procman.py

index 554fdbada88629222e889b77d6b01b180caeab63..87e3282224e8266e109a39e3c822bd8a20539908 100644 (file)
@@ -80,12 +80,16 @@ class ProcessManager:
         log.debug(u'ProcessManager.register(%s, %s, %s, %s, %s, %s, %s)',
                   name, command, callback, persist, max_errors, args, kwargs)
         assert not self.has(name)
         log.debug(u'ProcessManager.register(%s, %s, %s, %s, %s, %s, %s)',
                   name, command, callback, persist, max_errors, args, kwargs)
         assert not self.has(name)
-        self.services[name] = ProcessInfo(name, command, callback, persist,
-                                          max_errors, args, kwargs)
+        pi = ProcessInfo(name, command, callback, persist, max_errors,
+                        args, kwargs)
+        self.services[name] = pi
+        return pi
 
     def unregister(self, name):
         log.debug(u'ProcessManager.unregister(%s)', name)
 
     def unregister(self, name):
         log.debug(u'ProcessManager.unregister(%s)', name)
+        pi = self.services[name]
         del self.services[name]
         del self.services[name]
+        return pi
 
     def _call(self, pi):
         pi.start()
 
     def _call(self, pi):
         pi.start()
@@ -99,6 +103,7 @@ class ProcessManager:
         pi = ProcessInfo(name, command, callback, persist, max_errors,
                          args, kwargs)
         self._call(pi)
         pi = ProcessInfo(name, command, callback, persist, max_errors,
                          args, kwargs)
         self._call(pi)
+        return pi
 
     def start(self, name):
         log.debug(u'ProcessManager.start(%s)', name)
 
     def start(self, name):
         log.debug(u'ProcessManager.start(%s)', name)