<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Mar 13, 2012, at 10:44 PM, Itamar Turner-Trauring wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
  

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  
  <div bgcolor="#FFFFFF" text="#000000">
    twisted.internet.test.reactormixins says:<br>
    <blockquote>CFReactor uses APIs which manipulate global state, so
      it's not safe to run its own reactor-builder tests under itself.<br>
      <br>
    </blockquote>
    We also don't have a buildslave running under cfreactor. Which means
    it's currently completely untested. I filed a ticket to fix that -
    <a class="moz-txt-link-freetext" href="https://bugs.launchpad.net/twisted-buildbot-configuration/+bug/954680">https://bugs.launchpad.net/twisted-buildbot-configuration/+bug/954680</a><br></div></blockquote><div><br></div><div>Not <i>completely</i>&nbsp;untested. If you search a recent OS X build log, for example &lt;<a href="http://buildbot.twistedmatrix.com/builders/osx10.6-py2.6-select/builds/1952/steps/select/logs/stdio">http://buildbot.twistedmatrix.com/builders/osx10.6-py2.6-select/builds/1952/steps/select/logs/stdio</a>&gt;, you will see lots of "_CFReactor" tests that pass.</div><div><br></div><div>Ironically a builder run under CFReactor itself will test <i>less</i>&nbsp;code related to the CFReactor, because it will only run the haphazard tests that test the global reactor by returning Deferreds rather than running the reactor. &nbsp;But it does test different stuff, so there's value in having it run both ways.</div><div><br></div><blockquote type="cite"><div bgcolor="#FFFFFF" text="#000000">That still leaves the problem with global state though. Since we
    want to move towards having tests create new reactors, that's
    problematic. What global state does it manipulate, and what can we
    do about it?<br></div></blockquote><br></div><div>It manipulates the CoreFoundation run loop for its thread. &nbsp;Ironically, the reason that this is the case is that CF's API, much like Twisted itself, is not reentrant. &nbsp;If you're interested, &lt;<a href="http://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFRunLoopRef/Reference/reference.html">http://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFRunLoopRef/Reference/reference.html</a>&gt; is a pretty comprehensive reference.</div><div><br></div><div>We can't really do anything about it unless we can make Twisted start a new thread for each reactorbuilder test and then destroy the thread at the end. &nbsp;Or, unless we mock the whole CF API - which, honestly, isn't that hard, there aren't a ton of functions and they do pretty straightforward stuff.</div><div><br></div><div>-glyph</div><div><br></div><div><br></div></body></html>