Commit bdf9b9fd authored by Robin Obůrka's avatar Robin Obůrka Committed by Robin Obůrka

msgloop: Do not ignore StopIteration

Else branch for generator shouldn't be inside "main" while. It ignores
StopIteration and re-run generator again and again.
parent 6c29494d
......@@ -80,21 +80,22 @@ def init_env_data(box_name):
def _sn_main_loop(env_data, user_data, socket_recv, socket_send, setup=None, process=None, teardown=None):
while True:
if socket_recv:
try:
if socket_recv:
while True:
msg_in = socket_recv.recv_multipart()
msg_type, payload = parse_msg(msg_in)
result = process(env_data, user_data, msg_type, payload)
process_result(socket_send, result)
else:
for result in process(env_data, user_data):
process_result(socket_send, result)
except InvalidMsgError as e:
logger.error("Received broken message")
else:
for result in process(env_data, user_data):
process_result(socket_send, result)
def process_result(socket_send, result):
if not result:
......
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