def send_too_many_requests_response(self, properties, body):
     if properties.reply_to is not None:
         body_json = utils.str_to_json(body, self.fsencoding)[0]
         reply_msg = self.form_response_json(
             request_id=body_json['id'],
             status_code=requests.codes.too_many_requests,
             reply_body_str=constants.TOO_MANY_REQUESTS_BODY)
         LOGGER.debug(f"reply: ({ constants.TOO_MANY_REQUESTS_BODY})")
         self.send_response(reply_msg, properties)
Esempio n. 2
0
 def send_too_many_requests_response(self, msg):
     payload_json = utils.str_to_json(msg.payload, self.fsencoding)
     request_id = payload_json["headers"]["requestId"]
     LOGGER.debug(f"Replying with 'too many requests response' for "
                  f"request_id: {request_id} and msg id: {msg.mid}")
     response_json = self._mqtt_publisher.construct_response_json(
         request_id=request_id,
         status_code=requests.codes.too_many_requests,
         reply_body_str=constants.TOO_MANY_REQUESTS_BODY)
     self._mqtt_publisher.send_response(response_json)