From: Mukund Sivaraman Date: Fri, 5 Jul 2013 11:08:25 +0000 (+0530) Subject: [2856] Move command handlers into their own methods X-Git-Tag: bind10-1.2.0beta1-release~306^2~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=894180b8bfb30d7dfd7619cccffd0a2b4c3d4a2f;p=thirdparty%2Fkea.git [2856] Move command handlers into their own methods --- diff --git a/src/lib/python/isc/memmgr/builder.py b/src/lib/python/isc/memmgr/builder.py index 5b4eed94f7..317ae48324 100644 --- a/src/lib/python/isc/memmgr/builder.py +++ b/src/lib/python/isc/memmgr/builder.py @@ -50,6 +50,17 @@ class MemorySegmentBuilder: self._response_queue = response_queue self._shutdown = False + def __handle_shutdown(self): + self._shutdown = True + + def __handle_bad_command(self): + # A bad command was received. Raising an exception is not useful + # in this case as we are likely running in a different thread + # from the main thread which would need to be notified. Instead + # return this in the response queue. + self._response_queue.append(('bad_command',)) + self._shutdown = True + def run(self): """ This is the method invoked when the builder thread is started. In this thread, be careful when modifying @@ -76,19 +87,14 @@ class MemorySegmentBuilder: # "shutdown" command, which just exits the thread. for command in local_command_queue: if command == 'shutdown': - self._shutdown = True + self.__handle_shutdown() # When the shutdown command is received, we do # not process any further commands. break else: - # A bad command was received. Raising an - # exception is not useful in this case as we are - # likely running in a different thread from the - # main thread which would need to be - # notified. Instead return this in the response - # queue. - self._response_queue.append(('bad_command',)) - self._shutdown = True + self.__handle_bad_command() + # When a bad command is received, we do not + # process any further commands. break # Notify (any main thread) on the socket about a