Skip to content

Commit

Permalink
Change order of retry count checking
Browse files Browse the repository at this point in the history
Now sleep before retrying
  • Loading branch information
pjb304 committed Feb 4, 2019
1 parent 0171587 commit 457ee52
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sensirion_sps030/sensirion_sps030.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

DEFAULT_LOGGING_LEVEL = logging.WARN
DEFAULT_RETRY_COUNT = 3
RETRY_SLEEP = 2
MSG_START_STOP = b'\x7e'

CMD_ADDR = b'\x00'
Expand Down Expand Up @@ -263,9 +264,10 @@ def read_measurement(self):
except SensirionException as exp:
self.logger.warning("Attempt %d/%d failed", count, self.retries)
self.logger.error(str(exp))
count += 1 # increment counter
if count == self.retries:
raise exp
count += 1 # increment counter
sleep(RETRY_SLEEP)

def _tx(self, addr, cmd, data=[]):
"""
Expand Down

0 comments on commit 457ee52

Please sign in to comment.