Process an internal heartbeat response message.
514224
def handle_heartbeat_response(msg):
    """"""
    if not msg.gateway.is_sensor(msg.node_id):
        return None
    handle_smartsleep(msg)
    msg.gateway.sensors[msg.node_id].heartbeat = msg.payload
    msg.gateway.alert(msg)
    return None
1004679
def _on_msg(self, msg):
        """"""
        data = msg['content']['data']

        # If the message is a call invoke, run the function and send
        # the results.
        if 'callback' in data:
            guid = data['callback']
            callback = callback_registry[guid]
            args = data['arguments']
            args = [self.deserialize(a) for a in args]
            index = data['index']

            results = callback(*args)
            return self.serialize(self._send('return', index=index, results=results))

        # The message is not a call invoke, it must be an object
        # that is a response to a Python request.
        else:
            index = data['index']
            immutable = data['immutable']
            value = data['value']
            if index in self._callbacks:
                self._callbacks[index].resolve({
                    'immutable': immutable,
                    'value': value
                })
                del self._callbacks[index]
210842
def send_heart_beat_msg(self):
        ''''''
        if self.running:
            self.do_get_parameter()
            threading.Timer(HEARTBEAT_INTERVAL, self.send_heart_beat_msg).start()
470330
def process_message(message, notification):
    
    # Confirm that there are 'notificationType' and 'mail' fields in our
    # message
    if not set(VITAL_MESSAGE_FIELDS) <= set(message):
        # At this point we're sure that it's Amazon sending the message
        # If we don't return a 200 status code, Amazon will attempt to send us
        # this same message a few seconds later.
        logger.info('JSON Message Missing Vital Fields')
        return HttpResponse('Missing Vital Fields')

    if message['notificationType'] == 'Complaint':
        return process_complaint(message, notification)
    if message['notificationType'] == 'Bounce':
        return process_bounce(message, notification)
    if message['notificationType'] == 'Delivery':
        return process_delivery(message, notification)
    else:
        return HttpResponse('Unknown Notification Type')
1109611
def handle_incoming_response(self, call_id, payload):
        """"""
        self.log.debug('handle_incoming_response: in [typehint: %s, call ID: %s]',
                       payload['typehint'], call_id)  # We already log the full JSON response

        typehint = payload["typehint"]
        handler = self.handlers.get(typehint)

        def feature_not_supported(m):
            msg = feedback["handler_not_implemented"]
            self.editor.raw_message(msg.format(typehint, self.launcher.ensime_version))

        if handler:
            with catch(NotImplementedError, feature_not_supported):
                handler(call_id, payload)
        else:
            self.log.warning('Response has not been handled: %s', Pretty(payload))
75316
def handleNotification(self, handle, data):
        """"""
        _LOGGER.debug("Got notification from %s: %s", handle, codecs.encode(data, 'hex'))
        if handle in self._callbacks:
            self._callbacks[handle](data)
239245
def handle_data(self, data):
        """"""
        if 'id' in data:
            self.handle_response(data)
        else:
            self.handle_notification(data)
1258563
def _wait_receive_msg(self, timeout=0.25, type=2):
        """"""
        stamp = time.monotonic()
        while (time.monotonic() - stamp) < timeout:
            try:
                message = self._mq.receive(block=False, type=2)
                return message
            except sysv_ipc.BusyError:
                time.sleep(0.001) # wait a bit then retry!
        # uh-oh timed out
        raise RuntimeError("Timed out waiting for PulseIn message")
12926
function processResponse( xhr ){
    var responseText = xhr.responseText,
        status       = xhr.status,
        statusText,
        data;

    if ( !xhr ) {
        throw new Error( $.getString( "Errors.Security" ) );
    } else if ( xhr.status !== 200 && xhr.status !== 0 ) {
        status     = xhr.status;
        statusText = ( status == 404 ) ?
            "Not Found" :
            xhr.statusText;
        throw new Error( $.getString( "Errors.Status", status, statusText ) );
    }

    if( responseText.match(/\s*<.*/) ){
        try{
        data = ( xhr.responseXML && xhr.responseXML.documentElement ) ?
            xhr.responseXML :
            $.parseXml( responseText );
        } catch (e){
            data = xhr.responseText;
        }
    }else if( responseText.match(/\s*[\{\[].*/) ){
        try{
          data = $.parseJSON(responseText);
        } catch(e){
          data =  responseText;
        }
    }else{
        data = responseText;
    }
    return data;
}
1107971
def _process_response(self, reply):
        """"""
        self._advance_cluster_time(reply.get('$clusterTime'))
        self._advance_operation_time(reply.get('operationTime'))
        if self._in_transaction and self._transaction.sharded:
            recovery_token = reply.get('recoveryToken')
            if recovery_token:
                self._transaction.recovery_token = recovery_token
123349
def process_response(self, request, response):
        
        if hasattr(threadlocal, 'auditlog'):
            pre_save.disconnect(sender=LogEntry, dispatch_uid=threadlocal.auditlog['signal_duid'])

        return response
444429
def make_response(message, status_code, details=None):
    """"""
    response_body = dict(message=message)
    if details:
        response_body['details'] = details
    response = jsonify(response_body)
    response.status_code = status_code
    return response
151914
def proc_response(self, resp):
        """"""

        # Try to interpret any JSON
        try:
            resp.obj = json.loads(resp.body)
            self._debug("  Received entity: %r", resp.obj)
        except ValueError:
            resp.obj = None
            self._debug("  No received entity; body %r", resp.body)

        # Now, call superclass method for error handling
        super(JSONRequest, self).proc_response(resp)
114563
def _handle_heartbeat(self, sender, data):
        
        # Format of packet
        parsed, data = self._unpack("<B", data)
        format = parsed[0]
        if format == PACKET_FORMAT_VERSION:
            # Kind of beat
            parsed, data = self._unpack("<B", data)
            kind = parsed[0]
            if kind == PACKET_TYPE_HEARTBEAT:
                # Extract content
                parsed, data = self._unpack("<H", data)
                port = parsed[0]
                path, data = self._unpack_string(data)
                uid, data = self._unpack_string(data)
                node_uid, data = self._unpack_string(data)
                try:
                    app_id, data = self._unpack_string(data)
                except struct.error:
                    # Compatibility with previous version
                    app_id = herald.DEFAULT_APPLICATION_ID

            elif kind == PACKET_TYPE_LASTBEAT:
                # Peer is going away
                uid, data = self._unpack_string(data)
                app_id, data = self._unpack_string(data)
                port = -1
                path = None
                node_uid = None

            else:
                _logger.warning("Unknown kind of packet: %d", kind)
                return

            try:
                self._callback(kind, uid, node_uid, app_id, sender[0], port, path)
            except Exception as ex:
                _logger.exception("Error handling heart beat: %s", ex)
533429
def handler(self, reply):
        """"""
        data = reply.data
        while len(data):
            event, data = rq.EventField(None).parse_binary_value(data, self.display.display, None, None)
            if self.escape(event):  # Quit if this returns True
                self.stop()
            else:
                self._tap(event)
1281151
def handle_error(self):
        """"""
        if self.server.can_ignore_error(self):
            return
        if thread_local.status_code is None:
            msg("ERROR: Cannot send error status code! " +
                "Header already sent!\n{0}", traceback.format_exc())
        else:
            msg("ERROR: Error while processing request:\n{0}",
                traceback.format_exc())
            try:
                self.send_error(500, "Internal Error")
            except:  # nopep8
                if self.server.can_ignore_error(self):
                    return
                msg("ERROR: Cannot send error status code:\n{0}",
                    traceback.format_exc())
1357534
def heartbeat(self):
        
        if self._rpc is not None and self._rpc.is_active:
            self._rpc.send(types.StreamingPullRequest())