def WaitForResponse(self, ID, timeout=DefaultTimeout):
        """ Block and wait until stanza with specific "id" attribute will come.
            If no such stanza is arrived within timeout, return None.
            If operation failed for some reason then owner's attributes
            lastErrNode, lastErr and lastErrCode are set accordingly. """
        self._expected[ID]=None
        has_timed_out=0
        abort_time=time.time() + timeout
        self.DEBUG("Waiting for ID:%s with timeout %s..." % (ID,timeout),'wait')
        while not self._expected[ID]:
            if not self.Process(0.04):
                self._owner.lastErr="Disconnect"
                return None
            if time.time() > abort_time:
                self._owner.lastErr="Timeout"
                return None
        response=self._expected[ID]
        del self._expected[ID]
        if response.getErrorCode():
            self._owner.lastErrNode=response
            self._owner.lastErr=response.getError()
            self._owner.lastErrCode=response.getErrorCode()
        return response
dataset/ETHPy150Open CouchPotato/CouchPotatoServer/libs/xmpp/dispatcher.py/Dispatcher.WaitForResponse/original