From a48067c4c844fe84a0829b64cf0e1b5c3dac9005 Mon Sep 17 00:00:00 2001 From: Richard Belleville Date: Tue, 3 Aug 2021 11:08:31 -0700 Subject: [PATCH] Replace StopIteration with return (#26861) --- examples/python/cancellation/search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/python/cancellation/search.py b/examples/python/cancellation/search.py index 9d2331af1bb..28ac3664fc8 100644 --- a/examples/python/cancellation/search.py +++ b/examples/python/cancellation/search.py @@ -127,7 +127,7 @@ def search(target, hashes_computed = 0 for secret in _all_bytestrings(): if stop_event.is_set(): - raise StopIteration() # pylint: disable=stop-iteration-return + return candidate_hash = _get_hash(secret) distance = _get_substring_hamming_distance(candidate_hash, target) if interesting_hamming_distance is not None and distance <= interesting_hamming_distance: @@ -142,7 +142,7 @@ def search(target, secret=base64.b64encode(secret), hashed_name=candidate_hash, hamming_distance=distance) - raise StopIteration() # pylint: disable=stop-iteration-return + return hashes_computed += 1 if hashes_computed == maximum_hashes: raise ResourceLimitExceededError()