From 7b3d4d8f6a72393aa558a4727dd4d6c61b110fd9 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Wed, 11 Dec 2024 13:51:09 -0800 Subject: [PATCH] Add time between multi-response emits to help responses be handled synchronously Add note to address synchronization of responses --- neon_mq_connector/utils/client_utils.py | 1 + tests/test_utils.py | 1 + 2 files changed, 2 insertions(+) diff --git a/neon_mq_connector/utils/client_utils.py b/neon_mq_connector/utils/client_utils.py index 0a33369..13f935a 100644 --- a/neon_mq_connector/utils/client_utils.py +++ b/neon_mq_connector/utils/client_utils.py @@ -112,6 +112,7 @@ def handle_mq_response(channel: Channel, method, _, body): LOG.debug(f'MQ output: {api_output}') channel.basic_ack(delivery_tag=method.delivery_tag) if isinstance(api_output.get('_part'), int): + # TODO: Consider forcing these to be passed to `stream_callback` synchronously # Handle multi-part responses if stream_callback: # Pass each part to the stream callback method if defined diff --git a/tests/test_utils.py b/tests/test_utils.py index b25d481..b0749ca 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -128,6 +128,7 @@ def respond_multiple(channel, method, _, body): routing_key=reply_channel, body=dict_to_b64(response), properties=pika.BasicProperties(expiration='1000')) + time.sleep(0.5) # Used to ensure synchronous response handling channel.basic_ack(delivery_tag=method.delivery_tag)