def test_messages_without_actor_not_crashing_lookup_options( stub_broker, redis_result_backend): message = Message( queue_name="default", actor_name="idontexist", args=(), kwargs={}, options={}, ) assert Results(backend=redis_result_backend).after_nack( stub_broker, message) is None
def check_should_retry(msg, flag): if flag is False: message = Message( queue_name=msg['queue_name'], actor_name=msg['actor_name'], args=msg['args'], kwargs=msg['kwargs'], options={'on_success': 'check_should_retry'}, message_id=msg['message_id'], message_timestamp=msg['message_timestamp'] ) redis_broker.enqueue(message, delay=random.randrange(1000, 15000, 500))
def on_post(self, req: Request, resp): go_away = json.dumps({'ok': False, 'msg': 'go away'}) if not req.content_length: resp.status = falcon.HTTP_400 resp.body = go_away return # defaults to utf8 but should probably look at http headers to get this value, charset and stuff body = req.bounded_stream.read().decode('utf8') try: if not verify_signature( config.SLACK_SIGNING_SECRET, int(req.get_header('X-Slack-Request-Timestamp')), body, req.get_header('X-Slack-Signature')): resp.status = falcon.HTTP_401 resp.body = go_away return except ValueError as e: resp.status = falcon.HTTP_400 resp.body = json.dumps({'ok': False, 'msg': str(e)}) return doc = json.loads(body) callback_type = doc['type'] if callback_type == 'url_verification': resp.body = doc['challenge'] return if callback_type == 'event_callback': self.logger.debug(doc) self.rabbitmq_broker.enqueue( Message(queue_name='default', actor_name='slack_worker', args=(doc, ), options={}, kwargs={})) resp.body = json.dumps({'ok': True, 'msg': 'thanks!'})