From: Ben Darnell Date: Sun, 18 Jan 2015 21:33:11 +0000 (-0500) Subject: Fix test; cleanup whitespace. X-Git-Tag: v4.1.0b1~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c72fb2e39aa6e2a26b25f3432f5a453a3288a3d;p=thirdparty%2Ftornado.git Fix test; cleanup whitespace. --- diff --git a/tornado/gen.py b/tornado/gen.py index 0f5e134ae..2ec48dfb4 100644 --- a/tornado/gen.py +++ b/tornado/gen.py @@ -287,14 +287,13 @@ class WaitIterator(object): for k, v in kwargs.items(): self._keys.append(k) self._futures.append(v) - else: self._keys = None self._futures = list(args) - + self._queue = collections.deque() self._current_future = None - + for future in self._futures: if future.done(): self._queue.append(future) @@ -326,7 +325,7 @@ class WaitIterator(object): pass return self._running_future - + def current_index(self): """Returns the index of the current `.Future` from the argument list. If keyword arguments were used, the keyword @@ -334,7 +333,7 @@ class WaitIterator(object): """ if self._current_future: return self._current_future[0] - + def current_future(self): """Returns the current `.Future` object.""" if self._current_future: @@ -362,10 +361,10 @@ class WaitIterator(object): index = self._futures.index(done) ## Eliminate the reference for GC self._futures[index] = None - + if self._keys: index = self._keys[index] - + self._current_future = (index, done) class YieldPoint(object): diff --git a/tornado/test/gen_test.py b/tornado/test/gen_test.py index 270fc4589..692552f97 100644 --- a/tornado/test/gen_test.py +++ b/tornado/test/gen_test.py @@ -1091,7 +1091,7 @@ class WaitIteratorTest(AsyncTestCase): f1.set_result(24) f2.set_result(42) f3.set_result(84) - + g = gen.WaitIterator(f1, f2, f3) i = 0 for f in g: @@ -1114,7 +1114,7 @@ class WaitIteratorTest(AsyncTestCase): self.assertEqual(g.current_future(), None, "bad nil current future") dg = gen.WaitIterator(f1=f1, f2=f2) - + for df in dg: dr = yield df if dg.current_index() == "f1": @@ -1136,7 +1136,7 @@ class WaitIteratorTest(AsyncTestCase): if iteration == 3: futures[2].set_result(24) elif iteration == 5: - futures[0].set_exception(ZeroDivisionError) + futures[0].set_exception(ZeroDivisionError()) elif iteration == 8: futures[1].set_result(42) futures[3].set_result(84) @@ -1147,7 +1147,7 @@ class WaitIteratorTest(AsyncTestCase): @gen_test def test_iterator(self): futures = [Future(), Future(), Future(), Future()] - + self.finish_coroutines(0, futures) g = gen.WaitIterator(*futures)