Ticket #2556 defect closed fixed
cfreactor breaks twisted.trial
|Reported by:||bromine||Owned by:||bromine|
I have run into a number of problems trying to use cfreactor with twisted.trial.
from that folder. Python will hang in test.py, which just calls twisted.trial with --reactor cf testcase.py.
This problem is corrected by the attached diff. (The issue is that self.didStartRunLoop has to be set before calling runLoop.run() in order for the correct value of self.didStartRunLoop to be available inside the run loop.)
However, even fixing that still leaves two problems with running trial:
twisted/internet/cfreactor.py:294: exceptions.DeprecationWarning: reactor.crash cannot be used inside unit tests. By Twisted 2.7, using crash will fail the test and may crash or hang the test run. /Software/twisted/trial/reporter.py:219: twisted.trial.reporter.BrokenTestCaseWarning: REACTOR UNCLEAN! traceback(s) follow: Traceback (most recent call last): File "twisted/trial/unittest.py", line 652, in _classCleanUp util._Janitor().postClassCleanup() File "twisted/trial/util.py", line 68, in postClassCleanup 'cleanPending', 'cleanThreads') File "twisted/trial/util.py", line 72, in _dispatch getattr(self, "do_%s" % attr)() File "twisted/trial/util.py", line 126, in do_cleanReactor raise DirtyReactorError(' '.join(s)) twisted.trial.util.DirtyReactorError: THIS WILL BECOME AN ERROR SOON! reactor left in unclean state, the following Selectables were left over: <twisted.internet.posixbase._UnixWaker instance at 0x2a44af8>
Both of these are pointing at a mismatch between the semantics of reactors expected by trial and those actually implemented by cfreactor, but I don't know enough about either to know what the right way to fix this is.