diff --git a/eventlet/tpool.py b/eventlet/tpool.py index 9c35ffc..490a4ed 100644 --- a/eventlet/tpool.py +++ b/eventlet/tpool.py @@ -182,8 +182,10 @@ class Proxy(object): # the following are a buncha methods that the python interpeter # doesn't use getattr to retrieve and therefore have to be defined # explicitly + def __iter__(self): + return proxy_call(self._autowrap, self._obj.__iter__) def __getitem__(self, key): - return proxy_call(self._autowrap, self._obj.__getitem__, key) + return proxy_call(self._autowrap, self._obj.__getitem__, key) def __setitem__(self, key, value): return proxy_call(self._autowrap, self._obj.__setitem__, key, value) def __deepcopy__(self, memo=None): diff --git a/tests/tpool_test.py b/tests/tpool_test.py index 22869b9..001849c 100644 --- a/tests/tpool_test.py +++ b/tests/tpool_test.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import itertools import random from sys import stdout import time @@ -121,6 +122,14 @@ class TestTpool(LimitedTestCase): prox[1] = 2 self.assertEqual(prox[1], 2) + @skip_with_pyevent + def test_wrap_iterator(self): + prox = tpool.Proxy(xrange(10)) + result = [] + for i in prox: + result.append(i) + self.assertEquals(range(10), result) + @skip_with_pyevent def test_raising_exceptions(self): prox = tpool.Proxy(re)