diff options
author | Lianhao Lu <lianhao.lu@intel.com> | 2012-11-08 18:47:37 +0800 |
---|---|---|
committer | Lianhao Lu <lianhao.lu@intel.com> | 2012-11-14 09:28:05 +0800 |
commit | 33fbd87975aec414cfe5c9eaa8435ddae076f91f (patch) | |
tree | de1a078cd3f8f859c4f202c927c2a1f480c7608f /openstack/common/rpc | |
parent | d6fa3847cc64f6815641cdb549dd100e1aab6043 (diff) | |
download | oslo-33fbd87975aec414cfe5c9eaa8435ddae076f91f.tar.gz oslo-33fbd87975aec414cfe5c9eaa8435ddae076f91f.tar.xz oslo-33fbd87975aec414cfe5c9eaa8435ddae076f91f.zip |
Added initialize_service_hook for rpc.Service.
This fixes the collector part of the bug 1075463.
Declaring a consumer topic on the same rpc connection after the consume
thread has started would result the eventlet raise RuntimeError
exception. So all the declaring work should be done before calling
rpc.conn.consume_in_thread().
If the manager of a rpc.Service wants to declare topic consumers other
than the default ones created by rpc.Service.start(), it could define
the following hook in the manager class:
def initialize_service_hook(self, service):
#
# Do initialization work after rpc connection is created and before
# starting consuming thread.
# Params:
# service: handle to the rpc.Service instance.
Change-Id: I80001c32ee4e51e394fed827c91ad5e1eb0f94dc
Diffstat (limited to 'openstack/common/rpc')
-rw-r--r-- | openstack/common/rpc/service.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/openstack/common/rpc/service.py b/openstack/common/rpc/service.py index e572956..6b56ebb 100644 --- a/openstack/common/rpc/service.py +++ b/openstack/common/rpc/service.py @@ -57,6 +57,11 @@ class Service(service.Service): self.conn.create_consumer(self.topic, dispatcher, fanout=True) + # Hook to allow the manager to do other initializations after + # the rpc connection is created. + if callable(getattr(self.manager, 'initialize_service_hook', None)): + self.manager.initialize_service_hook(self) + # Consume from all consumers in a thread self.conn.consume_in_thread() |