Skip to content

Commit 77b83b1

Browse files
committed
check input_pulses length in read_pulses instead of try/except
1 parent 85bf019 commit 77b83b1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

adafruit_irremote.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def _read_pulses_non_blocking(self, input_pulses, max_pulse=10000, pulse_window=
205205
recent_count = 0
206206
pruning = False
207207
while True:
208-
try:
208+
while input_pulses:
209209
pulse = input_pulses.popleft()
210210
recent_count += 1
211211
if pulse > max_pulse:
@@ -216,11 +216,11 @@ def _read_pulses_non_blocking(self, input_pulses, max_pulse=10000, pulse_window=
216216
if received is None:
217217
received = []
218218
received.append(pulse)
219-
except IndexError:
220-
if recent_count == 0:
221-
return received
222-
recent_count = 0
223-
time.sleep(pulse_window)
219+
220+
if recent_count == 0:
221+
return received
222+
recent_count = 0
223+
time.sleep(pulse_window)
224224

225225
# pylint: disable-msg=too-many-arguments
226226
def read_pulses(self, input_pulses, max_pulse=10000, blocking=True,

0 commit comments

Comments
 (0)