Commit d06dc5ab authored by Federico Sismondi's avatar Federico Sismondi
Browse files

fine-tunning timers for avoiding UI error

parent 2479c2df
Pipeline #2057 passed with stage
in 0 seconds
...@@ -48,6 +48,9 @@ json_formatter = JsonFormatter() ...@@ -48,6 +48,9 @@ json_formatter = JsonFormatter()
rabbitmq_handler.setFormatter(json_formatter) rabbitmq_handler.setFormatter(json_formatter)
logger.addHandler(rabbitmq_handler) logger.addHandler(rabbitmq_handler)
# timer used to avoid bumpping into UI error (message dropped on two "simultaneous" messages arrival )
PUBLISH_DELAY = 0.1
mapping_testsuite_to_message_translator = { mapping_testsuite_to_message_translator = {
'dummy': DummySessionMessageTranslator, 'dummy': DummySessionMessageTranslator,
'coap': CoAPSessionMessageTranslator, 'coap': CoAPSessionMessageTranslator,
...@@ -190,6 +193,7 @@ class AmqpMessagePublisher: ...@@ -190,6 +193,7 @@ class AmqpMessagePublisher:
repr(message)[:STDOUT_MAX_STRING_LENGTH],)) repr(message)[:STDOUT_MAX_STRING_LENGTH],))
try: try:
time.sleep(PUBLISH_DELAY)
channel = self.connection.channel() channel = self.connection.channel()
channel.basic_publish( channel.basic_publish(
exchange=AMQP_EXCHANGE, exchange=AMQP_EXCHANGE,
...@@ -281,6 +285,7 @@ class AmqpMessagePublisher: ...@@ -281,6 +285,7 @@ class AmqpMessagePublisher:
)) ))
# fixme in amqp request use timeout instead of retries # fixme in amqp request use timeout instead of retries
time.sleep(PUBLISH_DELAY)
resp = amqp_request(self.connection, request, COMPONENT_ID, retries=timeout * 2) resp = amqp_request(self.connection, request, COMPONENT_ID, retries=timeout * 2)
return resp return resp
...@@ -662,7 +667,6 @@ def main(): ...@@ -662,7 +667,6 @@ def main():
# TODO implement a mechanism for not publish messages until previous one has been replied, # TODO implement a mechanism for not publish messages until previous one has been replied,
# how to handle the ui.user.request cancel command tho? # how to handle the ui.user.request cancel command tho?
time.sleep(0.2)
if not queue_messages_request_to_ui.empty(): if not queue_messages_request_to_ui.empty():
# get next request # get next request
request = queue_messages_request_to_ui.get() request = queue_messages_request_to_ui.get()
...@@ -675,7 +679,6 @@ def main(): ...@@ -675,7 +679,6 @@ def main():
request_message=request, request_message=request,
requested_field_name_list=requested_fields, requested_field_name_list=requested_fields,
) )
time.sleep(0.2)
# get next message reply from UI # get next message reply from UI
if not queue_messages_from_ui.empty(): if not queue_messages_from_ui.empty():
......
Supports Markdown
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