Skip to content

Commit 20b7197

Browse files
author
Anna Berleant
committed
do not retry on timeouts for non-idempotent commands
1 parent e0839a3 commit 20b7197

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

plotink/ebb3_serial.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,16 @@ def _send_request(self, type, request, request_name, num_tries = 3):
428428
raise RuntimeError(f'Error reported by EBB after {n_poll_count} polls.')
429429

430430
return response
431-
except RuntimeError as re:
431+
except RuntimeError as err:
432+
if 'Timed out' in err.args[0]:
433+
# it may not be appropriate to retry without knowing whether or not EBB received and executed the command
434+
# if the command was idempotent, we can safely retry:
435+
# if the command starts with "Q", it's a query and can be safely retried
436+
# also "SP" (set pen position) and "CU" (configure settings)
437+
if request_name[0] != 'Q' and request_name not in ["SP", "CU"]:
438+
raise
439+
440+
# retries!
432441
if num_tries > 1: # recursive case
433442
self.retry_count += 1
434443
self.port.reset_input_buffer() # clear out any inputs from EBB prior to the new request

0 commit comments

Comments
 (0)