From f2c1ee5a95b8a02c79c7014eface8c1ac4747386 Mon Sep 17 00:00:00 2001 From: Julius Unverfehrt Date: Mon, 14 Feb 2022 14:16:41 +0100 Subject: [PATCH] blacked --- mini_queue/consumer.py | 14 +++++--------- mini_queue/producer.py | 6 ++---- scripts/mock_publish.py | 7 ++++--- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/mini_queue/consumer.py b/mini_queue/consumer.py index f693fbc..c4c4f73 100644 --- a/mini_queue/consumer.py +++ b/mini_queue/consumer.py @@ -14,7 +14,9 @@ def callback(ch, method, properties, body): def init_params(): credentials = pika.PlainCredentials(CONFIG.rabbitmq.user, CONFIG.rabbitmq.password) - parameters = pika.ConnectionParameters(host=CONFIG.rabbitmq.host, port=CONFIG.rabbitmq.port, heartbeat=CONFIG.rabbitmq.heartbeat, credentials=credentials) + parameters = pika.ConnectionParameters( + host=CONFIG.rabbitmq.host, port=CONFIG.rabbitmq.port, heartbeat=CONFIG.rabbitmq.heartbeat, credentials=credentials + ) return parameters @@ -24,10 +26,8 @@ def consume(parameters, queue): channel = connection.channel() while True: try: - channel.basic_consume(queue=queue, - auto_ack=True, - on_message_callback=callback) - print(' [*] Waiting for messages. To exit press CTRL+C') + channel.basic_consume(queue=queue, auto_ack=True, on_message_callback=callback) + print(" [*] Waiting for messages. To exit press CTRL+C") channel.start_consuming() except pika.exceptions.ConnectionClosedByBroker: @@ -36,7 +36,3 @@ def consume(parameters, queue): pass except pika.exceptions.AMQPConnectionError: pass - - - - diff --git a/mini_queue/producer.py b/mini_queue/producer.py index f4ae359..fc44545 100644 --- a/mini_queue/producer.py +++ b/mini_queue/producer.py @@ -7,8 +7,6 @@ def produce_response(parameters, queue, body): connection = pika.BlockingConnection(parameters) channel = connection.channel() channel.queue_declare(queue=queue, durable=True) - channel.basic_publish("", - queue, - body) + channel.basic_publish("", queue, body) print(f" [x] Sent {body} on {queue}") - connection.close() \ No newline at end of file + connection.close() diff --git a/scripts/mock_publish.py b/scripts/mock_publish.py index a17a5ab..22fae71 100644 --- a/scripts/mock_publish.py +++ b/scripts/mock_publish.py @@ -4,11 +4,12 @@ from mini_queue.producer import produce_response from mini_queue.utils.config import CONFIG - if __name__ == "__main__": credentials = pika.PlainCredentials(CONFIG.rabbitmq.user, CONFIG.rabbitmq.password) queue = CONFIG.rabbitmq.queues.input - parameters = pika.ConnectionParameters(host=CONFIG.rabbitmq.host, port=CONFIG.rabbitmq.port, heartbeat=CONFIG.rabbitmq.heartbeat, credentials=credentials) + parameters = pika.ConnectionParameters( + host=CONFIG.rabbitmq.host, port=CONFIG.rabbitmq.port, heartbeat=CONFIG.rabbitmq.heartbeat, credentials=credentials + ) body = "Pika pika!" - produce_response(parameters, queue, body) \ No newline at end of file + produce_response(parameters, queue, body)