def buildReactor(self):
        """
        Create and return a reactor using C{self.reactorFactory}.
        """
        try:
            from twisted.internet.cfreactor import CFReactor
            from twisted.internet import reactor as globalReactor
        except __HOLE__:
            pass
        else:
            if (isinstance(globalReactor, CFReactor)
                and self.reactorFactory is CFReactor):
                raise SkipTest(
                    "CFReactor uses APIs which manipulate global state, "
                    "so it's not safe to run its own reactor-builder tests "
                    "under itself")
        try:
            reactor = self.reactorFactory()
        except:
            # Unfortunately, not all errors which result in a reactor
            # being unusable are detectable without actually
            # instantiating the reactor.  So we catch some more here
            # and skip the test if necessary.  We also log it to aid
            # with debugging, but flush the logged error so the test
            # doesn't fail.
            log.err(None, "Failed to install reactor")
            self.flushLoggedErrors()
            raise SkipTest(Failure().getErrorMessage())
        else:
            if self.requiredInterfaces is not None:
                missing = filter(
                     lambda required: not required.providedBy(reactor),
                     self.requiredInterfaces)
                if missing:
                    self.unbuildReactor(reactor)
                    raise SkipTest("%r does not provide %s" % (
                        reactor, ",".join([repr(x) for x in missing])))
        self.addCleanup(self.unbuildReactor, reactor)
        return reactor
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/internet/test/reactormixins.py/ReactorBuilder.buildReactor