Browse Source

[213] The forcefull argument

To really kill a component.
Michal 'vorner' Vaner 13 years ago
parent
commit
db063ad7e1

+ 7 - 2
src/lib/python/isc/bind10/component.py

@@ -269,16 +269,21 @@ class Component:
         """
         return self._procinfo.pid if self._procinfo else None
 
-    def kill(self):
+    def kill(self, forcefull=False):
         """
         The component should be forcefully killed. This does not change the
         internal state, it just kills the external process and expects a
         failure to be reported when the process really dies.
 
         If it isn't running, it does nothing.
+
+        If the forcefull is true, it uses SIGKILL instead of SIGTERM.
         """
         if self._procinfo:
-            self._procinfo.kill()
+            if forcefull:
+                self._procinfo.kill()
+            else:
+                self._procinfo.terminate()
 
 class Configurator:
     """

+ 2 - 1
src/lib/python/isc/bind10/special_component.py

@@ -44,7 +44,8 @@ class SockCreator(Component):
         """
         return self.__creator.pid() if self.__creator else None
 
-    def kill(self):
+    def kill(self, forcefull=False):
+        # We don't really care about forcefull here
         if self.__creator:
             self.__creator.kill()
 

+ 2 - 1
src/lib/python/isc/bind10/tests/component_test.py

@@ -433,6 +433,7 @@ class ComponentTests(BossUtils, unittest.TestCase):
         """
         component = Component(self, 'component', 'needed')
         component.kill()
+        component.kill(True)
 
 class TestComponent(Component):
     """
@@ -468,7 +469,7 @@ class TestComponent(Component):
     def _failed_internal(self):
         self.log('failed')
 
-    def kill(self):
+    def kill(self, forcefull=False):
         self.log('killed')
 
 class FailComponent(Component):