Replace 'raise StopIteration' with 'return'

With PEP 479, the behaviour of StopIteration is changing. Raising it to
stop a generator is considered incorrect and from Python 3.7 this will
cause a RuntimeError. The PEP recommends using the return statement.

More details: https://www.python.org/dev/peps/pep-0479/#examples-of-breakage

Change-Id: Ib27581fccbbf14c082fb919d8b6edea1ac83e3c0
This commit is contained in:
Dougal Matthews 2018-06-29 14:37:48 +01:00
parent 5de0494739
commit 044e6f20e6
2 changed files with 2 additions and 2 deletions

View File

@ -117,7 +117,7 @@ class Pool(object):
_, item = self._items.pop() _, item = self._items.pop()
yield item yield item
except IndexError: except IndexError:
raise StopIteration return
@abc.abstractmethod @abc.abstractmethod
def create(self): def create(self):

View File

@ -170,7 +170,7 @@ class RoutingTable(object):
hosts, tm_original = self._get_hosts(target_key) hosts, tm_original = self._get_hosts(target_key)
for host in itertools.cycle(hosts): for host in itertools.cycle(hosts):
if self._is_target_changed(target_key, tm_original): if self._is_target_changed(target_key, tm_original):
raise StopIteration() return
yield host yield host