Commit 9ff123be authored by Daniel Salzman's avatar Daniel Salzman

python/control: fix incomplete block read if error

parent 94dbffdf
......@@ -360,6 +360,7 @@ class KnotCtl(object):
"""
out = dict()
err_reply = None
while True:
reply = KnotCtlData()
......@@ -371,10 +372,14 @@ class KnotCtl(object):
# Check for an error.
if reply[KnotCtlDataIdx.ERROR]:
raise KnotCtlError(reply[KnotCtlDataIdx.ERROR], reply)
err_reply = reply
continue
self._receive_stats(out, reply)
if err_reply:
raise KnotCtlError(err_reply[KnotCtlDataIdx.ERROR], err_reply)
return out
def receive_block(self):
......@@ -384,17 +389,20 @@ class KnotCtl(object):
"""
out = dict()
err_reply = None
while True:
reply = KnotCtlData()
reply_type = self.receive(reply)
# Stop if not data type.
if reply_type not in [KnotCtlType.DATA, KnotCtlType.EXTRA]:
break
# Check for an error.
if reply[KnotCtlDataIdx.ERROR]:
raise KnotCtlError(reply[KnotCtlDataIdx.ERROR], reply)
err_reply = reply
continue
# Check for config data.
if reply[KnotCtlDataIdx.SECTION]:
......@@ -408,4 +416,7 @@ class KnotCtl(object):
else:
continue
if err_reply:
raise KnotCtlError(err_reply[KnotCtlDataIdx.ERROR], err_reply)
return out
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