Commit 2b132a1b authored by James Kirk's avatar James Kirk
Browse files

refactor: minor tidying up, linking issue, and improving err

parent 0638b941
......@@ -2,7 +2,7 @@ import json
import pika
host='localhost' # TODO Handle host being passed in
host='localhost' # TODO Handle host being passed in (https://git.noc.ac.uk/communications-backbone-system/communications-backbone/-/issues/17)
# -------------------------------------------------------------------------------------------------------------------------------------------------------------
......@@ -36,7 +36,7 @@ def deliver_to_exchange(channel, body, exchange_name, topic=None):
)
)
else:
topic_exchange(channel=channel, exchange_name=exchange_name, topic=topic)
topic_exchange(channel=channel, exchange_name=exchange_name)
channel.basic_publish(
exchange=exchange_name,
routing_key=topic,
......@@ -79,7 +79,7 @@ def read_from_queue(queue_name, max_msgs):
channel.basic_ack(method_frame.delivery_tag)
try:
messages.append(json.loads(body.decode()))
except:
except json.decoder.JSONDecodeError:
messages.append(body.decode())
else:
print("No message returned")
......@@ -161,7 +161,7 @@ def subscribe(queue_name, exchange_name, topic=None):
fanout_exchange(channel=channel, exchange_name=exchange_name)
channel.queue_bind(exchange=exchange_name, queue=queue_name)
else:
topic_exchange(channel=channel, exchange_name=exchange_name, topic=topic)
topic_exchange(channel=channel, exchange_name=exchange_name)
channel.queue_bind(exchange=exchange_name, queue=queue_name, routing_key=topic)
connection.close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment