Skip to content

Commit

Permalink
#68 Minor improvements in sleeping while fetching state
Browse files Browse the repository at this point in the history
  • Loading branch information
magoorden committed Aug 28, 2024
1 parent 41906c4 commit 5a227e7
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions py_driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,13 @@ def update_state(self, tube=None, quick=False, initial=False):
# wait for device to be ready again after requesting state
while not self.ready():
sleep(0.1)
total_wait += 0.1

# todo: not robust looking for {
if self.last_printed_buf_line > size_buffer and self.read_buffer[-2][0] == '{':
# If we received a line starting with {, we have received the new state.
break

sleep(0.1)
total_wait += 0.1

if total_wait > COMMUNICATION_TIMEOUT and self.ready():
raise RuntimeError(
f"Waiting too long for state to be communicated. {self.busy=}, {self.ready()=}")
Expand Down

0 comments on commit 5a227e7

Please sign in to comment.