From 4b464ffc63b64891b7356ac74cf3078faa6c267a Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 1 Feb 2018 11:25:41 +0100 Subject: [PATCH] allow NullFutures in gen.multi is_future() only accepts 'real' futures, but NullFutures work here, too. --- tornado/gen.py | 5 +---- tornado/test/gen_test.py | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tornado/gen.py b/tornado/gen.py index 2b51c5f8..0ceda1d5 100644 --- a/tornado/gen.py +++ b/tornado/gen.py @@ -814,10 +814,7 @@ def multi_future(children, quiet_exceptions=()): else: keys = None children = list(map(convert_yielded, children)) - # filter out NullFutures, like gen.moment - children = [child for child in children - if not isinstance(child, _NullFuture)] - assert all(is_future(i) for i in children) + assert all(is_future(i) or isinstance(i, _NullFuture) for i in children) unfinished_children = set(children) future = _create_future() diff --git a/tornado/test/gen_test.py b/tornado/test/gen_test.py index f33ac3ca..12621cec 100644 --- a/tornado/test/gen_test.py +++ b/tornado/test/gen_test.py @@ -1603,10 +1603,12 @@ class RunnerGCTest(AsyncTestCase): # now that it's not a real Future @gen.coroutine def wait_a_moment(): - yield gen.multi([gen.moment, gen.moment]) + result = yield gen.multi([gen.moment, gen.moment]) + raise gen.Return(result) loop = self.get_new_ioloop() - loop.run_sync(wait_a_moment) + result = loop.run_sync(wait_a_moment) + self.assertEqual(result, [None, None]) if __name__ == '__main__':