Skip to content

Commit

Permalink
connect attempts: Minor refactor to use range() when possible
Browse files Browse the repository at this point in the history
Modification to #464
  • Loading branch information
projectgus committed Jan 15, 2020
1 parent ea8a13d commit b04c237
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions esptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,7 @@ def connect(self, mode='default_reset', attempts=DEFAULT_CONNECT_ATTEMPTS):
last_error = None

try:
for attempt in itertools.count():
if attempts > 0 and attempt >= attempts:
break
for _ in range(attempts) if attempts > 0 else itertools.count():
last_error = self._connect_attempt(mode=mode, esp32r0_delay=False)
if last_error is None:
return
Expand Down Expand Up @@ -2839,7 +2837,7 @@ def main(custom_commandline=None):

parser.add_argument(
'--connect-attempts',
help=('Number of attempts to connect, negative or 0 for infinate. '
help=('Number of attempts to connect, negative or 0 for infinite. '
'Default: %d.' % DEFAULT_CONNECT_ATTEMPTS),
type=int,
default=os.environ.get('ESPTOOL_CONNECT_ATTEMPTS', DEFAULT_CONNECT_ATTEMPTS))
Expand Down

0 comments on commit b04c237

Please sign in to comment.