]> git.llucax.com Git - software/pymin.git/commitdiff
Check for name uniqueness when a new process is added to ProcessManager.
authorLeandro Lucarella <llucax@gmail.com>
Sat, 17 May 2008 05:36:46 +0000 (02:36 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Wed, 21 May 2008 16:01:56 +0000 (13:01 -0300)
This check is against both current running processes (namemap) and the
registered processes (services) to ensure that the name is unique and so
process gets overriden.

pymin/procman.py

index adfa792ca68be7ecc0c5f924fd7d8f76df17653b..4fc75a8949b3ad21adfe22ae1ce470c43123cce8 100644 (file)
@@ -72,6 +72,7 @@ class ProcessManager:
                 max_errors=3, *args, **kwargs):
         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)
 
@@ -87,6 +88,7 @@ class ProcessManager:
                 max_errors=3, *args, **kwargs):
         log.debug(u'ProcessManager.call(%s, %s, %s, %s, %s, %s, %s)',
                   name, command, callback, persist, max_errors, args, kwargs)
+        assert not self.has(name)
         pi = ProcessInfo(name, command, callback, persist, max_errors,
                          args, kwargs)
         self._call(pi)