'Run the reactor for at most the given amount of time.
@param reactor: The reactor to run.
@type timeout: C{int} or C{float}
@param timeout: The maximum amount of time, specified in seconds, to
allow the reactor to run.  If the reactor is still running after
this much time has elapsed, it will be stopped and an exception
raised.  If L{None}, the default test method timeout imposed by
Trial will be used.  This depends on the L{IReactorTime}
implementation of C{reactor} for correct operation.
@raise TestTimeoutError: If the reactor is still running after
C{timeout} seconds.'

def runReactor(self, reactor, timeout=None):

    if (timeout is None):
        timeout = self.getTimeout()
    timedOut = []
    def stop():
        timedOut.append(None)
        reactor.stop()
    timedOutCall = reactor.callLater(timeout, stop)
    reactor.run()
    if timedOut:
        raise TestTimeoutError(('reactor    still    running    after    %s    seconds' % (timeout,)))
    else:
        timedOutCall.cancel()
