From 9d6372b7aeb3c0a8f46ac6c993ba7d95415557dd Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 27 Apr 2017 21:23:48 -0700 Subject: [PATCH] Shutdown a endpoint workers executor on termination There is a pool of threads that are typically used here in this executor, to be safe shut it down on worker/consumer shutdown (the python interpreter will also do this on exist, but its better to be explicit than not). Change-Id: I374233a1cc1b7995a96d79532c0208cd355185ba --- octavia/controller/queue/consumer.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/octavia/controller/queue/consumer.py b/octavia/controller/queue/consumer.py index bd088e2160..7d1c9cd7c1 100644 --- a/octavia/controller/queue/consumer.py +++ b/octavia/controller/queue/consumer.py @@ -30,7 +30,7 @@ class ConsumerService(cotyledon.Service): self.conf = conf self.topic = conf.oslo_messaging.topic self.server = conf.host - self.endpoints = [endpoint.Endpoint()] + self.endpoints = [] self.access_policy = dispatcher.DefaultRPCAccessPolicy self.message_listener = None @@ -39,6 +39,7 @@ class ConsumerService(cotyledon.Service): transport = messaging.get_transport(self.conf) target = messaging.Target(topic=self.topic, server=self.server, fanout=False) + self.endpoints = [endpoint.Endpoint()] self.message_listener = messaging.get_rpc_server( transport, target, self.endpoints, executor='threading', access_policy=self.access_policy) @@ -53,4 +54,11 @@ class ConsumerService(cotyledon.Service): _LI('Consumer successfully stopped. Waiting for final ' 'messages to be processed...')) self.message_listener.wait() + if self.endpoints: + LOG.info(_LI('Shutting down endpoint worker executors...')) + for e in self.endpoints: + try: + e.worker.executor.shutdown() + except AttributeError: + pass super(ConsumerService, self).terminate()