From 044e6f20e65084f3c4ecc554672d3271b2a2acd3 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Fri, 29 Jun 2018 14:37:48 +0100 Subject: [PATCH] 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 --- oslo_messaging/_drivers/pool.py | 2 +- oslo_messaging/_drivers/zmq_driver/client/zmq_routing_table.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/oslo_messaging/_drivers/pool.py b/oslo_messaging/_drivers/pool.py index 681dbef1e..774c3ab34 100644 --- a/oslo_messaging/_drivers/pool.py +++ b/oslo_messaging/_drivers/pool.py @@ -117,7 +117,7 @@ class Pool(object): _, item = self._items.pop() yield item except IndexError: - raise StopIteration + return @abc.abstractmethod def create(self): diff --git a/oslo_messaging/_drivers/zmq_driver/client/zmq_routing_table.py b/oslo_messaging/_drivers/zmq_driver/client/zmq_routing_table.py index 458563314..40fc9669a 100644 --- a/oslo_messaging/_drivers/zmq_driver/client/zmq_routing_table.py +++ b/oslo_messaging/_drivers/zmq_driver/client/zmq_routing_table.py @@ -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