Rename MessageHandlingServer._executor for readability

MessageHandlingServer has both MessageHandlingServer.executor, which
is the name of an executor type, and MessageHandlingServer._executor,
which is an instance of that type. Ideally we would rename
MessageHandlingServer.executor, but as this is referenced from outside
the class we change _executor instead to _executor_obj.

Change-Id: Id69ba7a0729cc66d266327dac2fd4eab50f2814c
This commit is contained in:
Matthew Booth 2015-10-19 10:31:50 +01:00
parent 4f49b7e253
commit aec50602d5
2 changed files with 13 additions and 13 deletions
oslo_messaging

@ -112,7 +112,7 @@ class MessageHandlingServer(service.ServiceBase):
raise ExecutorLoadFailure(self.executor, ex)
else:
self._executor_cls = mgr.driver
self._executor = None
self._executor_obj = None
self._running = False
super(MessageHandlingServer, self).__init__()
@ -131,19 +131,19 @@ class MessageHandlingServer(service.ServiceBase):
choose to dispatch messages in a new thread, coroutine or simply the
current thread.
"""
if self._executor is not None:
if self._executor_obj is not None:
return
with self._state_cond:
if self._executor is not None:
if self._executor_obj is not None:
return
try:
listener = self.dispatcher._listen(self.transport)
except driver_base.TransportDriverError as ex:
raise ServerListenError(self.target, ex)
self._running = True
self._executor = self._executor_cls(self.conf, listener,
self.dispatcher)
self._executor.start()
self._executor_obj = self._executor_cls(self.conf, listener,
self.dispatcher)
self._executor_obj.start()
self._state_cond.notify_all()
def stop(self):
@ -155,9 +155,9 @@ class MessageHandlingServer(service.ServiceBase):
server are still in use. See 'wait' for more details.
"""
with self._state_cond:
if self._executor is not None:
if self._executor_obj is not None:
self._running = False
self._executor.stop()
self._executor_obj.stop()
self._state_cond.notify_all()
def wait(self):
@ -190,8 +190,8 @@ class MessageHandlingServer(service.ServiceBase):
" messages to finish processing, it has"
" been %0.2f seconds and stop() still has"
" not been called"), w.elapsed())
executor = self._executor
self._executor = None
executor = self._executor_obj
self._executor_obj = None
if executor is not None:
# We are the lucky calling thread to wait on the executor to
# actually finish.

@ -120,14 +120,14 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin):
server = oslo_messaging.get_rpc_server(transport, target, endpoints,
serializer=serializer)
# Mocking executor
server._executor = mock.Mock()
server._executor_obj = mock.Mock()
# Here assigning executor's listener object to listener variable
# before calling wait method, because in wait method we are
# setting executor to None.
listener = server._executor.listener
listener = server._executor_obj.listener
# call server wait method
server.wait()
self.assertIsNone(server._executor)
self.assertIsNone(server._executor_obj)
self.assertEqual(1, listener.cleanup.call_count)
def test_no_target_server(self):