From ec28a305d91139ef5d307fa56ad289a635e37a90 Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Mon, 9 Nov 2015 22:47:29 +0800 Subject: [PATCH] Removing wait() when initializing notification listener According to [1],the correct usage is to call stop() before wait(), so in mistral case, we should never call stop() and wait() in initialization of engine and executor service. [1]: http://docs.openstack.org/developer/oslo.messaging/notification_listener.html Change-Id: Ic6a802bff35a6a6fdfadf38474782efd12fd34d8 Closes-Bug: #1514459 --- mistral/cmd/launch.py | 25 +++++++++++++++++++++---- mistral/tests/unit/engine/base.py | 22 ++++++++++++++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/mistral/cmd/launch.py b/mistral/cmd/launch.py index 358610715..f65871fa5 100755 --- a/mistral/cmd/launch.py +++ b/mistral/cmd/launch.py @@ -25,6 +25,7 @@ eventlet.monkey_patch( time=True) import os +import time # If ../mistral/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... @@ -76,8 +77,16 @@ def launch_executor(transport): executor_v2.register_membership() - server.start() - server.wait() + try: + server.start() + while True: + time.sleep(604800) + except (KeyboardInterrupt, SystemExit): + pass + finally: + print("Stopping executor service...") + server.stop() + server.wait() def launch_engine(transport): @@ -107,8 +116,16 @@ def launch_engine(transport): engine_v2.register_membership() - server.start() - server.wait() + try: + server.start() + while True: + time.sleep(604800) + except (KeyboardInterrupt, SystemExit): + pass + finally: + print("Stopping engine service...") + server.stop() + server.wait() def launch_api(transport): diff --git a/mistral/tests/unit/engine/base.py b/mistral/tests/unit/engine/base.py index d4b99ae75..1151b683f 100644 --- a/mistral/tests/unit/engine/base.py +++ b/mistral/tests/unit/engine/base.py @@ -44,8 +44,15 @@ def launch_engine_server(transport, engine): serializer=ctx.RpcContextSerializer(ctx.JsonPayloadSerializer()) ) - server.start() - server.wait() + try: + server.start() + while True: + eventlet.sleep(604800) + except (KeyboardInterrupt, SystemExit): + LOG.info("Stopping engine service...") + finally: + server.stop() + server.wait() def launch_executor_server(transport, executor): @@ -62,8 +69,15 @@ def launch_executor_server(transport, executor): serializer=ctx.RpcContextSerializer(ctx.JsonPayloadSerializer()) ) - server.start() - server.wait() + try: + server.start() + while True: + eventlet.sleep(604800) + except (KeyboardInterrupt, SystemExit): + LOG.info("Stopping executor service...") + finally: + server.stop() + server.wait() class EngineTestCase(base.DbTestCase):