Python wait response

45 Python code examples are found related to " wait response". You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
Example 1
Source File: recorder.py    From aws-builders-fair-projects with Apache License 2.0 6 votes vote down vote up
def waitForResponse():
    myAWSIoTMQTTClient = AWSIoTMQTTClient(clientId)
    myAWSIoTMQTTClient.configureEndpoint(host, port)
    myAWSIoTMQTTClient.configureCredentials(rootCAPath, privateKeyPath, certificatePath)
    myAWSIoTMQTTClient.configureAutoReconnectBackoffTime(1, 32, 20)
    myAWSIoTMQTTClient.configureOfflinePublishQueueing(-1)  # Infinite offline Publish queueing
    myAWSIoTMQTTClient.configureDrainingFrequency(2)  # Draining: 2 Hz
    myAWSIoTMQTTClient.configureConnectDisconnectTimeout(10)  # 10 sec
    myAWSIoTMQTTClient.configureMQTTOperationTimeout(5)  # 5 sec
    myAWSIoTMQTTClient.connect()
    myAWSIoTMQTTClient.subscribe(topic, 1, customCallback)
    time.sleep(2)

    # Publish to the same topic in a loop forever
    loopCount = 0
    while True:
        time.sleep(2) 
Example 2
Source File: remote_master.py    From avocado-vt with GNU General Public License v2.0 6 votes vote down vote up
def wait_response(self, cmd):
        """
        Wait until command return any cmd.
        """
        if cmd.cmd_id not in self.cmds:
            return cmd
        if cmd.is_finished() or cmd._stdout_cnt or cmd._stderr_cnt:
            return cmd
        m_cmd = self.cmds[cmd.cmd_id]

        r_cmd = None

        time_step = None
        timeout = cmd.timeout
        if timeout is not None:
            time_step = timeout / 10.0
        w = wait_timeout(timeout)
        while (next(w)):
            r_cmd = self.listen_messenger(time_step)
            if r_cmd is not None and r_cmd == m_cmd.basecmd:
                return m_cmd

        if r_cmd is None:
            raise CmdTimeout(timeout) 
Example 3
Source File: dispatcher.py    From python-for-android with Apache License 2.0 6 votes vote down vote up
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 
Example 4
Source File: repl.py    From Dumb-Cogs with MIT License 6 votes vote down vote up
def wait_for_first_response(tasks, converters):
    """given a list of unawaited tasks and non-coro result parsers to be called on the results,
    this function returns the 1st result that is returned and converted

    if it is possible for 2 tasks to complete at the same time,
    only the 1st result deteremined by asyncio.wait will be returned

    returns None if none successfully complete
    returns 1st error raised if any occur (probably)
    """
    primed = [wait_for_result(t, c) for t, c in zip(tasks, converters)]
    done, pending = await asyncio.wait(primed, return_when=asyncio.FIRST_COMPLETED)
    for p in pending:
        p.cancel()

    try:
        return done.pop().result()
    except NotImplementedError as e:
        raise e
    except:
        return None 
Example 5
Source File: iosxr_install_package.py    From iosxr-ansible with GNU General Public License v3.0 6 votes vote down vote up
def wait_install_response(module, oper_id):
    retries = 100
    while retries > 0:
        if is_install_in_progress(module):
            retries -= 1
            time.sleep(3)
        else:
            response = list()
            for inst_id in oper_id:
                command = "show install log " + inst_id
                rmsg = module.execute(command)
                if 'aborted' in rmsg[0]:
                    module.fail_json(msg=rmsg[0])
                response.append(rmsg[0])
            return response
    else:
        module.fail_json(msg="timeout waiting for install to complete")

# get install operation id from log 
Example 6
Source File: session.py    From aries-cloudagent-python with Apache License 2.0 6 votes vote down vote up
def wait_response(self) -> Union[str, bytes]:
        """Wait for a response to be buffered and pack it."""
        while True:
            if self._closed:
                return
            if self.response_buffer:
                response = self.response_buffer.enc_payload
                if not response:
                    try:
                        response = await self.encode_outbound(self.response_buffer)
                    except WireFormatError as e:
                        LOGGER.warning("Error encoding direct response: %s", str(e))
                        self.clear_response()
                if response:
                    return response
            self.response_event.clear()
            await self.response_event.wait() 
Example 7
Source File: auth_handler.py    From imoocc with GNU General Public License v2.0 6 votes vote down vote up
def wait_for_response(self, event):
        while True:
            event.wait(0.1)
            if not self.transport.is_active():
                e = self.transport.get_exception()
                if (e is None) or issubclass(e.__class__, EOFError):
                    e = AuthenticationException('Authentication failed.')
                raise e
            if event.isSet():
                break
        if not self.is_authenticated():
            e = self.transport.get_exception()
            if e is None:
                e = AuthenticationException('Authentication failed.')
            # this is horrible.  python Exception isn't yet descended from
            # object, so type(e) won't work. :(
            if issubclass(e.__class__, PartialAuthentication):
                return e.allowed_types
            raise e
        return [] 
Example 8
Source File: redis_connection.py    From pyvivado with MIT License 6 votes vote down vote up
def wait_for_response(self, timeout=None):
        waittime = 0.1
        got_response = False
        waiting_time = 0
        while (not got_response) and ((timeout is None) or (waiting_time < timeout)):
            response = r.get(self.name)
            if response[0] == ord('R'):
                got_response=True
            r.set(self.listened, datetime.datetime.now().strftime('%Y%m%d%H%M%S'))
            time.sleep(waittime)
            waiting_time += waittime
        split_response = response.split()
        rsp = Response(
                length=len(split_response[3:]),
                data=[int(v.decode('ascii'), 16) for v in split_response[3:]],
                resp=0,
                )
        return rsp 
Example 9
Source File: CreateAccountScreen.py    From Pirates-Online-Rewritten with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def enterWaitForLoginResponse(self):
        self.cr.handler = self.handleWaitForLoginResponse
        self.cr.userName = self.userName
        self.cr.password = self.password
        try:
            data = {}
            referrer = launcher.getReferrerCode()
            if referrer is not None:
                data['referrer'] = referrer
            error = self.loginInterface.createAccount(self.userName, self.password, data)
        except TTAccount.TTAccountException, e:
            error = str(e)
            self.notify.info(error)
            self.dialog.setMessage(error + OTPLocalizer.CreateAccountScreenConnectionErrorSuffix)
            self.dialog.show()
            self.acceptOnce(self.dialogDoneEvent, self.__handleConnectionErrorAck)
            return 
Example 10
Source File: OltRemoveFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_get_onu_id_by_port_id_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211MsgGetOnuIdByPortIdResponse in pkt:
            log.debug('[RESPONSE] PAS5211MsgGetOnuIdByPortIdResponse')
            self.send_unset_port_id_downlink_policing(self.device.device, 1, self.port_id)
            raise self.wait_unset_port_id_downlink_policing_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 11
Source File: OltInstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_set_port_id_policing_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211SetPortIdPolicingConfigResponse in pkt:
            log.debug('[RESPONSE] PAS5211SetPortIdPolicingConfigResponse')
            raise self.end()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 12
Source File: OltInstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_set_gen_vlan_uplink_configuration_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211SetVlanGenConfigResponse in pkt:
            log.debug('[RESPONSE] PAS5211SetVlanGenConfigResponse')
            self.send_set_port_id_configuration(self.device.device, PON_ENABLE, self.port_id, self.alloc_id)
            raise self.wait_set_port_id_configuration_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 13
Source File: OltInstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_remove_downlink_policing_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211RemoveDownstreamPolicingConfigResponse in pkt:
            log.debug('[RESPONSE] PAS5211RemoveDownstreamPolicingConfigResponse')
            self.send_set_downlink_policing(self.device.device, self.downlink_bandwidth)
            raise self.wait_set_downlink_policing_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 14
Source File: OltInstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_set_vlan_downlink_configuration_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211SetVlanDownConfigResponse in pkt:
            log.debug('[RESPONSE] PAS5211SetVlanDownConfigResponse')
            self.send_set_downlink_vlan_handling(self.device.device, self.cvlan_id, self.svlan_id, self.port_id)
            raise self.wait_set_downlink_vlan_handling_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 15
Source File: OltInstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_get_port_id_downlink_policing_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211GetPortIdDownstreamPolicingConfigResponse in pkt:
            log.debug('[RESPONSE] PAS5211GetPortIdDownstreamPolicingConfigResponse')
            if pkt[PAS5211GetPortIdDownstreamPolicingConfigResponse].ds_policing_config_id != PMC_OFAL_NO_POLICY:
                self.policy_id = pkt[PAS5211GetPortIdDownstreamPolicingConfigResponse].ds_policing_config_id
                log.debug('Policy id got: {}'.format(self.policy_id))
                self.send_unset_port_id_downlink_policing(self.device.device, 1, self.port_id)
                raise self.wait_unset_port_id_downlink_policing_response()
            else:
                self.send_set_downlink_policing(self.device.device,self.downlink_bandwidth)
                raise self.wait_set_downlink_policing_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 16
Source File: OltInstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_set_downlink_vlan_handling_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211SetDownVlanHandlResponse in pkt:
            log.debug('[RESPONSE] PAS5211SetDownVlanHandlResponse')
            self.send_get_port_id_downlink_policing(self.device.device, self.port_id)
            raise self.wait_get_port_id_downlink_policing_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 17
Source File: btchipComm.py    From HWI with MIT License 5 votes vote down vote up
def waitFirstResponse(self, timeout):
		start = time.time()
		data = ""
		while len(data) == 0:
			data = self.device.read(65)
			if not len(data):
				if time.time() - start > timeout:
					raise BTChipException("Timeout")
				time.sleep(0.02)
		return bytearray(data) 
Example 18
Source File: OltInstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_set_svlan_at_configuration_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211SetSVlanAtConfigResponse in pkt:
            log.debug('[RESPONSE] PAS5211SetSVlanAtConfigResponse')
            self.send_set_vlan_uplink_configuration(self.device.device, self.port_id)
            raise self.wait_set_vlan_uplink_configuration_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 19
Source File: APIProxy.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_response(self, pkt):
        if PAS5211MsgHeader in pkt: # and not isinstance(pkt, OmciFrame):
            log.debug("adaptor-rcv", adaptor=self.adaptor_agent)
            self.adaptor_agent.receive_proxied_message(self.proxy_address, pkt['PAS5211MsgHeader'])
            raise self.end() 
Example 20
Source File: OltRemoveFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_unset_port_id_downlink_policing_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211UnsetPortIdPolicingConfigResponse in pkt:
            log.debug('[RESPONSE] PAS5211UnsetPortIdPolicingConfigResponse')
            self.send_set_port_id_configuration(self.device.device, PON_DISABLE, self.port_id, self.alloc_id)
            raise self.wait_set_port_id_configuration_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 21
Source File: OltInstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_set_uplink_vlan_handling_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211SetUplinkVlanHandlResponse in pkt:
            log.debug('[RESPONSE] PAS5211SetUplinkVlanHandlResponse')
            self.send_set_gen_vlan_downlink_configuration(self.device.device)
            raise self.wait_set_gen_vlan_downlink_configuration_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 22
Source File: OltReinstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_set_port_id_configuration_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211MsgSetPortIdConfigResponse in pkt:
            log.debug('[RESPONSE] PAS5211MsgSetPortIdConfigResponse')
            olt = OltInstallFlowStateMachine(iface=self.iface, comm=self.comm,
                    target=self.target, device=self.device, onu_id=self.onu_id,
                    channel_id=self.channel_id, port_id=self.port_id, onu_session_id=self.onu_session_id,
                    alloc_id=self.alloc_id, svlan_id= self.svlan_id, cvlan_id=self.cvlan_id)
            olt.runbg()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 23
Source File: OltInstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_set_gen_vlan_downlink_configuration_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211SetVlanGenConfigResponse in pkt:
            log.debug('[RESPONSE] PAS5211SetVlanGenConfigResponse')
            self.send_set_vlan_downlink_configuration(self.device.device, self.svlan_id)
            raise self.wait_set_vlan_downlink_configuration_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 24
Source File: OltInstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_set_downlink_policing_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211SetDownstreamPolicingConfigResponse in pkt:
            log.debug('[RESPONSE] PAS5211SetDownstreamPolicingConfigResponse')
            # if pkt[PAS5211SetDownstreamPolicingConfigResponse].policing_config_id:
            self.policy_id = pkt[PAS5211SetDownstreamPolicingConfigResponse].policing_config_id
            log.debug('Policy id set: {}'.format(self.policy_id))
            self.send_set_port_id_policing(self.device.device, 1, self.port_id, self.policy_id)
            raise self.wait_set_port_id_policing_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 25
Source File: OltInstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_send_dba_algorithm_msg_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211MsgSendDbaAlgorithmMsgResponse in pkt:
            log.debug('[RESPONSE] PAS5211MsgSendDbaAlgorithmMsgResponse')
            self.send_set_svlan_at_configuration(self.device.device, self.svlan_id)
            raise self.wait_set_svlan_at_configuration_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 26
Source File: OMCIProxy.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_send_response(self, pkt):
        if PAS5211MsgSendFrameResponse in pkt:
            raise self.wait_event()

    # Transitions from wait_event 
Example 27
Source File: comm.py    From blue-loader-python with Apache License 2.0 5 votes vote down vote up
def waitFirstResponse(self, timeout):
		start = time.time()
		data = ""
		while len(data) == 0:
			data = self.device.read(65)
			if not len(data):
				if time.time() - start > timeout:
					raise CommException("Timeout")
				time.sleep(0.0001)
		return bytearray(data) 
Example 28
Source File: client.py    From DjangoChannelsGraphqlWs with MIT License 5 votes vote down vote up
def wait_response(self, response_checker, timeout=None):
        """Wait for particular response skipping all intermediate ones.

        Useful when you need to need to wait until subscription reports
        desired state or skip subscription messages between request and
        response.

        Args:
            response_checker: Function with accepts GraphQL response as
                single parameter and must return `True` for desired
                response and `False` the other responses.
            timeout: Seconds to wait until response is received.

        Returns:
            Response payload, same as `receive`.

        Raises:
            `asyncio.TimeoutError` when timeout is reached.

        """
        if timeout is None:
            timeout = self._transport.TIMEOUT
        while timeout > 0:
            start = time.monotonic()
            try:
                response = await self.receive()
                if response_checker(response):
                    return response
            except asyncio.TimeoutError:
                # Ignore `receive` calls timeout until wait timeout
                # is reached.
                pass
            timeout -= time.monotonic() - start
        raise asyncio.TimeoutError 
Example 29
Source File: cast_socket.py    From pulseaudio-dlna with GNU General Public License v3.0 5 votes vote down vote up
def wait_for_response_type(self, _type, timeout=10):
        start_time = time.time()
        while True:
            if not self._is_socket_readable():
                time.sleep(0.1)
            else:
                response = self.read()
                self._add_to_response_cache(response)
                if response.get('type', None) == _type:
                    return response
            current_time = time.time()
            if current_time - start_time > timeout:
                raise NoResponseException()
        return None 
Example 30
Source File: cast_socket.py    From pulseaudio-dlna with GNU General Public License v3.0 5 votes vote down vote up
def wait_for_response_id(self, req_id, timeout=10):
        start_time = time.time()
        while True:
            if not self._is_socket_readable():
                time.sleep(0.1)
            else:
                response = self.read()
                self._add_to_response_cache(response)
                if req_id in self.response_cache:
                    return response
            current_time = time.time()
            if current_time - start_time > timeout:
                raise NoResponseException()
        return None 
Example 31
Source File: fleetprovisioning.py    From aws-iot-device-sdk-python-v2 with Apache License 2.0 5 votes vote down vote up
def waitForCreateCertificateFromCsrResponse():
    # Wait for the response.
    loopCount = 0
    while loopCount < 10 and createCertificateFromCsrResponse is None:
        if createCertificateFromCsrResponse is not None:
            break
        print('Waiting...CreateCertificateFromCsrResponse: ' + json.dumps(createCertificateFromCsrResponse))
        loopCount += 1
        time.sleep(1) 
Example 32
Source File: fleetprovisioning.py    From aws-iot-device-sdk-python-v2 with Apache License 2.0 5 votes vote down vote up
def waitForCreateKeysAndCertificateResponse():
    # Wait for the response.
    loopCount = 0
    while loopCount < 10 and createKeysAndCertificateResponse is None:
        if createKeysAndCertificateResponse is not None:
            break
        print('Waiting... CreateKeysAndCertificateResponse: ' + json.dumps(createKeysAndCertificateResponse))
        loopCount += 1
        time.sleep(1) 
Example 33
Source File: fleetprovisioning.py    From aws-iot-device-sdk-python-v2 with Apache License 2.0 5 votes vote down vote up
def waitForRegisterThingResponse():
    # Wait for the response.
    loopCount = 0
    while loopCount < 20 and registerThingResponse is None:
        if registerThingResponse is not None:
            break
        loopCount += 1
        print('Waiting... RegisterThingResponse: ' + json.dumps(registerThingResponse))
        time.sleep(1) 
Example 34
Source File: fyflash.py    From fygimbal with MIT License 5 votes vote down vote up
def waitResponse(command):
    print("Waiting for %02x" % command)
    while True:
        for packet in rx.parse(port.read(1)):
            if packet.framing == fyproto.LONG_FORM:
                if packet.command == command:
                    print("RX %s" % packet)
                    return packet 
Example 35
Source File: __init__.py    From loopchain with Apache License 2.0 5 votes vote down vote up
def request_server_wait_response(stub_method, message, time_out_seconds=None):
    """서버로 gRPC 메시지를 타임아웃 설정안에서 응답이 올때까지 반복 요청한다.

    :param stub_method: gRPC stub.method
    :param message: gRPC proto message
    :param time_out_seconds: time out seconds
    :return: gRPC response
    """

    if time_out_seconds is None:
        time_out_seconds = conf.CONNECTION_RETRY_TIMEOUT
    start_time = timeit.default_timer()
    duration = timeit.default_timer() - start_time

    while duration < time_out_seconds:
        try:
            response = stub_method(message, conf.GRPC_TIMEOUT)

            if hasattr(response, "response_code") and response.response_code == message_code.Response.success:
                return response
            elif hasattr(response, "status") and response.status != "":
                return response
        except Exception as e:
            logging.warning("retry request_server_in_time: " + str(e))
            logging.debug("duration(" + str(duration)
                          + ") interval(" + str(conf.CONNECTION_RETRY_INTERVAL)
                          + ") timeout(" + str(time_out_seconds) + ")")

        # RETRY_INTERVAL 만큼 대기후 TIMEOUT 전이면 다시 시도
        time.sleep(conf.CONNECTION_RETRY_INTERVAL)
        duration = timeit.default_timer() - start_time

    return None 
Example 36
Source File: btchipwallet.py    From encompass with GNU General Public License v3.0 5 votes vote down vote up
def waitFirstResponse(self, timeout):
            customTimeout = 0
            while customTimeout < timeout:
                try:
                    response = self.dongle.waitFirstResponse(200)
                    return response
                except USBError, e:
                    if e.backend_error_code == -7:
                        QApplication.processEvents()
                        customTimeout = customTimeout + 100
                        pass
                    else:
                        raise e 
Example 37
Source File: OltInstallFlowStateMachine.py    From voltha with Apache License 2.0 5 votes vote down vote up
def wait_for_set_vlan_uplink_configuration_response(self, pkt):
        #log.debug('api-proxy-response')
        if PAS5211SetVlanUplinkConfigurationResponse in pkt:
            log.debug('[RESPONSE] PAS5211SetVlanUplinkConfigurationResponse')
            self.send_set_uplink_vlan_handling(self.device.device, self.port_id, self.cvlan_id, self.svlan_id)
            raise self.wait_set_uplink_vlan_handling_response()
        else:
            log.debug('Unexpected pkt {}'.format(pkt.summary())) 
Example 38
Source File: http.py    From vlcp with Apache License 2.0 5 votes vote down vote up
def wait_for_response_end(self, container, connection, connmark, xid):
        if not connection.connected or connection.connmark != connmark:
            return False
        elif connection.http_responsexid > xid + 1:
            return True
        elif connection.http_responsexid == xid + 1 and connection.http_parsestage in ('end', 'headline', 'headers'):
            return connection.http_parsestage != 'end'
        else:
            re = HttpResponseEndEvent.createMatcher(connection, connmark, xid)
            rc = self.statematcher(connection)
            ev, m = await M_(re, rc)
            if m is re:
                return ev.keepalive
            else:
                return False 
Example 39
Source File: backend_session.py    From janus-cloud with GNU Affero General Public License v3.0 5 votes vote down vote up
def wait_response(self, timeout=None):
        ready = self._response_ready.wait(timeout=timeout)
        if not ready:
            raise JanusCloudError('Request {} Timeout for backend Janus server: {}'.format(self.request_msg, self._url),
                                  JANUS_ERROR_GATEWAY_TIMEOUT)
        return self._response 
Example 40
Source File: OTPClientRepository.py    From Pirates-Online-Rewritten with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def waitForGetGameListResponse(self):
        if self.isGameListCorrect():
            self.loginFSM.request('waitForShardList')
        else:
            self.loginFSM.request('missingGameRootObject') 
Example 41
Source File: CreateAccountScreen.py    From Pirates-Online-Rewritten with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def handleWaitForLoginResponse(self, msgType, di):
        if msgType == CLIENT_LOGIN_2_RESP:
            self.handleLoginResponseMsg2(di)
        elif msgType == CLIENT_LOGIN_RESP:
            self.handleLoginResponseMsg(di)
        else:
            self.cr.handleMessageType(msgType, di) 
Example 42
Source File: utils.py    From bottery with MIT License 5 votes vote down vote up
def wait_response(f):
    def decorator(view):
        async def wrapper(message):
            message._response_handler = f
            if asyncio.iscoroutinefunction(view):
                return await view(message)
            return view(message)
        return wrapper
    return decorator 
Example 43
Source File: service.py    From ATX with Apache License 2.0 5 votes vote down vote up
def wait_response(rid, timeout=1):
    timeout = time.time() + timeout
    while timeout > time.time():
        with service_response_lock:
            if rid in responses:
                return responses.pop(rid)
        time.sleep(0.1)
    # cleanup timeouted response, avoid memory leak by add a placeholder!
    with service_response_lock:
        if rid in responses:
            del responses[rid]
        else:
            responses[rid] = None 
Example 44
Source File: lcmUtils.py    From director with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def waitForResponse(self, timeout=5000, keepAlive=True):
        response = getNextMessage(self.subscriber, self.messageClass, timeout)
        if not keepAlive:
            self.finish()
        return response 
Example 45
Source File: client.py    From nsq-py with MIT License 5 votes vote down vote up
def wait_response(self):
        '''Wait for a response'''
        responses = self.read()
        while not responses:
            responses = self.read()
        return responses