From 775819e87c7fdab3be95b6e31ee974fa61329850 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Thu, 15 Dec 2016 13:13:22 -0500 Subject: [PATCH] Bugfix to shutdown and restart for the test suite. --- module_build_service/scheduler/consumer.py | 10 +++++----- tests/test_build/test_build.py | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/module_build_service/scheduler/consumer.py b/module_build_service/scheduler/consumer.py index 27fd0f29..9896b7d6 100644 --- a/module_build_service/scheduler/consumer.py +++ b/module_build_service/scheduler/consumer.py @@ -91,17 +91,14 @@ class MBSConsumer(fedmsg.consumers.FedmsgConsumer): self.sanity_check() def shutdown(self): - log.info("Shutting down..") - self.hub.stop() + log.info("Scheduling shutdown.") from moksha.hub.reactor import reactor + reactor.callFromThread(self.hub.stop) reactor.callFromThread(reactor.stop) def consume(self, message): log.info("Received %r" % message) - if self.stop_condition and self.stop_condition(message): - return self.shutdown() - # Sometimes, the messages put into our queue are artificially put there # by other parts of our own codebase. If they are already abstracted # messages, then just use them as-is. If they are not already @@ -120,6 +117,9 @@ class MBSConsumer(fedmsg.consumers.FedmsgConsumer): log.exception('Failed while handling {0!r}'.format(msg.msg_id)) log.info(msg) + if self.stop_condition and self.stop_condition(message): + self.shutdown() + def get_abstracted_msg(self, message): # Convert the message to an abstracted message if conf.messaging == 'fedmsg': diff --git a/tests/test_build/test_build.py b/tests/test_build/test_build.py index 66f36ed8..f6aff7b5 100644 --- a/tests/test_build/test_build.py +++ b/tests/test_build/test_build.py @@ -189,6 +189,7 @@ class TestBuild(unittest.TestCase): import sys del sys.modules['twisted.internet.reactor'] del sys.modules['moksha.hub.reactor'] + del sys.modules['moksha.hub'] import moksha.hub.reactor @timed(30)