-def await_some_reply(fd, block=False):
- received_nothing = True
- while received_nothing:
+def print_line(line):
+ try:
+ response = line.decode('ascii').strip()
+ except UnicodeDecodeError:
+ print("decoding failed.")
+ response = str(line)
+ print(response)
+
+
+def await_some_reply(fd, wait_for_ok=False, timeout=5):
+ ba = bytearray()
+ stop_time = time() + (timeout if wait_for_ok else 0.3)
+ while True: