Bugfix to shutdown and restart for the test suite.

This commit is contained in:
Ralph Bean
2016-12-15 13:13:22 -05:00
committed by Matt Prahl
parent 9d3b85426d
commit 775819e87c
2 changed files with 6 additions and 5 deletions

View File

@@ -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':

View File

@@ -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)