From a641baa97866e5dba7b1e61a3d22a31fa5be6f56 Mon Sep 17 00:00:00 2001 From: Thomas Herve Date: Wed, 2 Sep 2015 10:54:30 +0200 Subject: [PATCH] Use thread executor all the time for notifier Trying to use the greenlet executor doesn't work when we don't use taskflow, as nothing is doing the monkeypatching. Let's use threads for now. Closes-Bug: #1491326 Change-Id: Ic59f75a883eff1d4f0e4683f9d8ea4d943ad7aac --- zaqar/notification/notifier.py | 7 ++----- zaqar/tests/unit/notification/test_notifier.py | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/zaqar/notification/notifier.py b/zaqar/notification/notifier.py index ad0d633ba..4a7d077d0 100644 --- a/zaqar/notification/notifier.py +++ b/zaqar/notification/notifier.py @@ -29,11 +29,8 @@ class NotifierDriver(object): def __init__(self, *args, **kwargs): self.subscription_controller = kwargs.get('subscription_controller') - try: - self.executor = futurist.GreenThreadPoolExecutor() - except RuntimeError: - # TODO(flwang): Make the max_workers configurable - self.executor = futurist.ThreadPoolExecutor(max_workers=10) + # TODO(flwang): Make the max_workers configurable + self.executor = futurist.ThreadPoolExecutor(max_workers=10) def post(self, queue_name, messages, client_uuid, project=None): """Send messages to the subscribers.""" diff --git a/zaqar/tests/unit/notification/test_notifier.py b/zaqar/tests/unit/notification/test_notifier.py index 82e512689..fec31a69f 100644 --- a/zaqar/tests/unit/notification/test_notifier.py +++ b/zaqar/tests/unit/notification/test_notifier.py @@ -51,6 +51,7 @@ class NotifierTest(testing.TestBase): with mock.patch('requests.post') as mock_post: self.driver.post('fake_queue', self.messages, self.client_id, self.project) + self.driver.executor.shutdown() mock_post.assert_has_calls([ mock.call(self.subscription[0]['subscriber'], data=json.dumps(self.messages[0]),