config_helper: wait_for_service_response makes many calls to LRANGE
Just a report
Summary
In wait_for_service_response
one can see:
while True:
res = self.producer.lrange(MessageEndpoints.service_response(RID), 0, -1)
if not res:
time.sleep(0.005)
elapsed_time += 0.005
else:
service_messages = [messages.ServiceResponseMessage.loads(msg) for msg in res]
ack_services = [
msg.content["response"]["service"]
for msg in service_messages
if msg is not None
]
if set(["DeviceServer", "ScanServer"]).issubset(set(ack_services)):
break
if elapsed_time > max_time:
...
So, there are many calls to LRANGE
in order to determine if the device server service or
the scan server service have replied. If there are responses, all responses are re-read
until the 2 services we wait for have replied.
Then there is a timeout management in order to break with an exception if the answers are
not received in due time.
Expected Behavior vs Actual Behavior
It would be more efficient to wait until something is added to the list, and to read list elements one by one.