Parcourir la source

[2856] Pass tuples in the command queue

Mukund Sivaraman il y a 12 ans
Parent
commit
e291894070

+ 1 - 1
src/bin/memmgr/memmgr.py.in

@@ -162,7 +162,7 @@ class Memmgr(BIND10Server):
         # This makes the MemorySegmentBuilder exit its main loop. It
         # This makes the MemorySegmentBuilder exit its main loop. It
         # should make the builder thread joinable.
         # should make the builder thread joinable.
         with self._builder_cv:
         with self._builder_cv:
-            self._builder_command_queue.append('shutdown')
+            self._builder_command_queue.append(('shutdown',))
             self._builder_cv.notify_all()
             self._builder_cv.notify_all()
 
 
         self._builder_thread.join()
         self._builder_thread.join()

+ 2 - 1
src/lib/python/isc/memmgr/builder.py

@@ -85,7 +85,8 @@ class MemorySegmentBuilder:
                 # Run commands passed in the command queue sequentially
                 # Run commands passed in the command queue sequentially
                 # in the given order.  For now, it only supports the
                 # in the given order.  For now, it only supports the
                 # "shutdown" command, which just exits the thread.
                 # "shutdown" command, which just exits the thread.
-                for command in local_command_queue:
+                for command_tuple in local_command_queue:
+                    command = command_tuple[0]
                     if command == 'shutdown':
                     if command == 'shutdown':
                         self.__handle_shutdown()
                         self.__handle_shutdown()
                         # When the shutdown command is received, we do
                         # When the shutdown command is received, we do

+ 4 - 4
src/lib/python/isc/memmgr/tests/builder_tests.py

@@ -58,7 +58,7 @@ class TestMemorySegmentBuilder(unittest.TestCase):
         # Now that the builder thread is running, send it a bad
         # Now that the builder thread is running, send it a bad
         # command. The thread should exit its main loop and be joinable.
         # command. The thread should exit its main loop and be joinable.
         with self._builder_cv:
         with self._builder_cv:
-            self._builder_command_queue.append('bad_command')
+            self._builder_command_queue.append(('bad_command',))
             self._builder_cv.notify_all()
             self._builder_cv.notify_all()
 
 
         # Wait 5 seconds to receive a notification on the socket from
         # Wait 5 seconds to receive a notification on the socket from
@@ -98,10 +98,10 @@ class TestMemorySegmentBuilder(unittest.TestCase):
         # Now that the builder thread is running, send it the shutdown
         # Now that the builder thread is running, send it the shutdown
         # command. The thread should exit its main loop and be joinable.
         # command. The thread should exit its main loop and be joinable.
         with self._builder_cv:
         with self._builder_cv:
-            self._builder_command_queue.append('shutdown')
+            self._builder_command_queue.append(('shutdown',))
             # Commands after 'shutdown' must be ignored.
             # Commands after 'shutdown' must be ignored.
-            self._builder_command_queue.append('bad_command_1')
-            self._builder_command_queue.append('bad_command_2')
+            self._builder_command_queue.append(('bad_command_1',))
+            self._builder_command_queue.append(('bad_command_2',))
             self._builder_cv.notify_all()
             self._builder_cv.notify_all()
 
 
         # Wait 5 seconds at most for the main loop of the builder to
         # Wait 5 seconds at most for the main loop of the builder to