'Take a Deferred that only ever callbacks. Block until it happens.'

def _wait(self, d, running=_wait_is_running):

    if running:
        raise RuntimeError('_wait    is    not    reentrant')
    from twisted.internet import reactor
    results = []
    def append(any):
        if (results is not None):
            results.append(any)
    def crash(ign):
        if (results is not None):
            reactor.crash()
    crash = utils.suppressWarnings(crash, util.suppress(message='reactor\\.crash    cannot    be    used.*', category=DeprecationWarning))
    def stop():
        reactor.crash()
    stop = utils.suppressWarnings(stop, util.suppress(message='reactor\\.crash    cannot    be    used.*', category=DeprecationWarning))
    running.append(None)
    try:
        d.addBoth(append)
        if results:
            return
        d.addBoth(crash)
        reactor.stop = stop
        try:
            reactor.run()
        finally:
            del reactor.stop
        if (results or self._timedOut):
            return
        raise KeyboardInterrupt()
    finally:
        results = None
        running.pop()
