diff --git a/pyinfra/config.py b/pyinfra/config.py index 5927171..937b760 100644 --- a/pyinfra/config.py +++ b/pyinfra/config.py @@ -7,14 +7,13 @@ from pyinfra.locations import CONFIG_FILE def make_art(): return """ -______ _____ __ -| ___ \ |_ _| / _| -| |_/ / _ | | _ __ | |_ _ __ __ _ -| __/ | | || || '_ \| _| '__/ _` | -| | | |_| || || | | | | | | | (_| | -\_| \__, \___/_| |_|_| |_| \__,_| - __/ | - |___/ + ___ _ _ ___ __ + o O O | _ \ | || | |_ _| _ _ / _| _ _ __ _ + o | _/ \_, | | | | ' \ | _| | '_| / _` | + TS__[O] _|_|_ _|__/ |___| |_||_| _|_|_ _|_|_ \__,_| + {======|_| ``` |_| ````|_|`````|_|`````|_|`````|_|`````|_|`````| +./o--000' `-0-0-' `-0-0-' `-0-0-' `-0-0-' `-0-0-' `-0-0-' `-0-0-' + """ diff --git a/pyinfra/flask.py b/pyinfra/flask.py index fcddb97..549ef0c 100644 --- a/pyinfra/flask.py +++ b/pyinfra/flask.py @@ -58,7 +58,7 @@ def set_up_probing_webserver(): logger.warning(f"Got no metrics from analysis prometheus endpoint: {err}") informed_about_missing_prometheus_endpoint = True else: - raise err + logging.warning(f"Caught {err}") return resp.text return app diff --git a/pyinfra/queue/queue_manager/pika_queue_manager.py b/pyinfra/queue/queue_manager/pika_queue_manager.py index 75e1596..3b91fea 100644 --- a/pyinfra/queue/queue_manager/pika_queue_manager.py +++ b/pyinfra/queue/queue_manager/pika_queue_manager.py @@ -45,7 +45,12 @@ def get_connection(): credentials = pika.PlainCredentials(username=CONFIG.rabbitmq.user, password=CONFIG.rabbitmq.password) - kwargs = {"host": CONFIG.rabbitmq.host, "port": CONFIG.rabbitmq.port, "credentials": credentials} + kwargs = { + "host": CONFIG.rabbitmq.host, + "port": CONFIG.rabbitmq.port, + "credentials": credentials, + "heartbeat": CONFIG.rabbitmq.heartbeat, + } parameters = pika.ConnectionParameters(**kwargs) @@ -96,7 +101,7 @@ class PikaQueueManager(QueueManager): def publish_response(self, message, callback, max_attempts=3): - logger.debug(f"Publishing response for {message}.") + logger.debug(f"Processing {message}.") frame, properties, body = message diff --git a/scripts/mock_client.py b/scripts/mock_client.py index 89b2b90..e7699fa 100644 --- a/scripts/mock_client.py +++ b/scripts/mock_client.py @@ -54,6 +54,8 @@ def build_message_bodies(analyse_container_type): storage = get_s3_storage() for bucket_name, pdf_name in storage.get_all_object_names(CONFIG.storage.bucket): + if "pdf" not in pdf_name: + continue file_id = pdf_name.split(".")[0] dossier_id, file_id = file_id.split("/") message_dict = {"dossierId": dossier_id, "fileId": file_id} @@ -74,6 +76,7 @@ def main(args): for method_frame, _, body in channel.consume(queue=CONFIG.rabbitmq.queues.output): print(f"Received {json.loads(body)}") channel.basic_ack(method_frame.delivery_tag) + channel.close() if __name__ == "__main__": diff --git a/src/serve.py b/src/serve.py index 1948abf..7e26ce4 100644 --- a/src/serve.py +++ b/src/serve.py @@ -54,11 +54,11 @@ def main(): @retry(ConsumerError, tries=3, delay=5, jitter=(1, 3)) def consume(): + consumer = Consumer(visitor, queue_manager) try: - consumer = Consumer(visitor, queue_manager) consumer.consume_and_publish() except Exception as err: - raise ConsumerError from err + raise ConsumerError() from err try: consume()