The iterator is infinite on purpose (it has no reason to be finite).
You'd terminate it from outside, either when the operation succeeds, so the example loop should more properly be something along the lines of:
for _ in backoff(): try: c = connect_to_a_thing() break except ConnectionError: pass # retry
for _ in itertools.islice(backoff(), 5): # do stuff
The iterator is infinite on purpose (it has no reason to be finite).
You'd terminate it from outside, either when the operation succeeds, so the example loop should more properly be something along the lines of:
or you'd use composition to e.g. stop after a set number of tries: most likely a combination of both.