#28 - stop using Thread as CleverSwarm methods are not thread-safe
Unit test coverage / pytest (push) Failing after 59s
Unit test coverage / pytest (pull_request) Failing after 1m20s

This commit is contained in:
Stanislav Hejny
2025-05-02 10:05:36 +01:00
parent d681b8ae0f
commit e29b7339f9
3 changed files with 14 additions and 5 deletions
+12 -3
View File
@@ -75,12 +75,21 @@ class DataMessageHandler:
self.file_handler: FileHandler = file_handler
self.backpressure_handler: BackpressureHandler = backpressure_handler
async def inbound_data_message_callback(self, message: AbstractIncomingMessage):
async def inbound_data_message_callback_as_thread(
self, message: AbstractIncomingMessage
):
"""
The callback method that is called when a DataMessage is received from RabbitMQ, starts new Thread.
"""
threading.Thread(
target=lambda: asyncio.run(self.run_callback_thread(message))
target=lambda: asyncio.run(
self.inbound_data_message_callback_no_thread(message)
)
).start()
async def run_callback_thread(self, message: AbstractIncomingMessage):
async def inbound_data_message_callback_no_thread(
self, message: AbstractIncomingMessage
):
"""
Receives the DataMessage as bytes from RabbitMQ queue and deserializes it to the DataMessage object
Ensures Jaeger trace-id propagation.
+1 -1
View File
@@ -107,7 +107,7 @@ class AMQService:
try:
await self.rabbit_mq_client.register_inbound_routes(
route_mapping,
self.amq_data_message_handler.inbound_data_message_callback,
self.amq_data_message_handler.inbound_data_message_callback_no_thread,
)
return await self.rabbit_mq_client.register_data_reply_callback(
self.amq_data_message_handler.reply_received_callback
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "amq_adapter"
version = "0.2.25"
version = "0.2.26"
description = "The Python implementation of the AMQ Adapter for CleverMicro"
readme = "README.md"
authors = [