Skip to content

Commit

Permalink
Fix twistedlayered test.
Browse files Browse the repository at this point in the history
Disable a test that fails under the trollius IOLoop.

Disable some additional logging.
  • Loading branch information
bdarnell committed Oct 3, 2015
1 parent 50665e0 commit dddd721
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions tornado/test/twisted_test.py
Expand Up @@ -552,6 +552,10 @@ def fn():
# with py27+, but not unittest2 on py26.
'test_changeGID',
'test_changeUID',
# This test sometimes fails with EPIPE on a call to
# kqueue.control. Happens consistently for me with
# trollius but not asyncio or other IOLoops.
'test_childConnectionLost',
],
# Process tests appear to work on OSX 10.7, but not 10.6
# 'twisted.internet.test.test_process.PTYProcessTestsBuilder': [
Expand Down Expand Up @@ -676,6 +680,14 @@ def unbuildReactor(self, reactor):
# log.startLoggingWithObserver(log.PythonLoggingObserver().emit, setStdout=0)
# import logging; logging.getLogger('twisted').setLevel(logging.WARNING)

# Twisted recently introduced a new logger; disable that one too.
try:
from twisted.logger import globalLogBeginner
except ImportError:
pass
else:
globalLogBeginner.beginLoggingTo([])

if have_twisted:
class LayeredTwistedIOLoop(TwistedIOLoop):
"""Layers a TwistedIOLoop on top of a TornadoReactor on a SelectIOLoop.
Expand All @@ -689,7 +701,7 @@ def initialize(self, **kwargs):
# When configured to use LayeredTwistedIOLoop we can't easily
# get the next-best IOLoop implementation, so use the lowest common
# denominator.
self.real_io_loop = SelectIOLoop()
self.real_io_loop = SelectIOLoop(make_current=False)
reactor = TornadoReactor(io_loop=self.real_io_loop)
super(LayeredTwistedIOLoop, self).initialize(reactor=reactor, **kwargs)
self.add_callback(self.make_current)
Expand All @@ -709,7 +721,12 @@ def stop(self):
# tornado-on-twisted-on-tornado. I'm clearly missing something
# about the startup/crash semantics, but since stop and crash
# are really only used in tests it doesn't really matter.
self.reactor.callWhenRunning(self.reactor.crash)
def f():
self.reactor.crash()
# Become current again on restart. This is needed to
# override real_io_loop's claim to being the current loop.
self.add_callback(self.make_current)
self.reactor.callWhenRunning(f)

if __name__ == "__main__":
unittest.main()

0 comments on commit dddd721

Please sign in to comment.