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:
parent
5de0494739
commit
044e6f20e6
@ -117,7 +117,7 @@ class Pool(object):
|
||||
_, item = self._items.pop()
|
||||
yield item
|
||||
except IndexError:
|
||||
raise StopIteration
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def create(self):
|
||||
|
@ -170,7 +170,7 @@ class RoutingTable(object):
|
||||
hosts, tm_original = self._get_hosts(target_key)
|
||||
for host in itertools.cycle(hosts):
|
||||
if self._is_target_changed(target_key, tm_original):
|
||||
raise StopIteration()
|
||||
return
|
||||
yield host
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user