changeset: 91696:e4fe6706b7b4 branch: 3.4 parent: 91694:6d5a76214166 user: Victor Stinner date: Wed Jul 16 18:50:39 2014 +0200 files: Lib/asyncio/tasks.py Lib/test/test_asyncio/test_tasks.py description: Issue #21163: Fix "destroy pending task" warning in test_wait_errors() diff -r 6d5a76214166 -r e4fe6706b7b4 Lib/asyncio/tasks.py --- a/Lib/asyncio/tasks.py Wed Jul 16 18:36:24 2014 +0200 +++ b/Lib/asyncio/tasks.py Wed Jul 16 18:50:39 2014 +0200 @@ -330,14 +330,14 @@ raise TypeError("expect a list of futures, not %s" % type(fs).__name__) if not fs: raise ValueError('Set of coroutines/Futures is empty.') + if return_when not in (FIRST_COMPLETED, FIRST_EXCEPTION, ALL_COMPLETED): + raise ValueError('Invalid return_when value: {}'.format(return_when)) if loop is None: loop = events.get_event_loop() fs = {async(f, loop=loop) for f in set(fs)} - if return_when not in (FIRST_COMPLETED, FIRST_EXCEPTION, ALL_COMPLETED): - raise ValueError('Invalid return_when value: {}'.format(return_when)) return (yield from _wait(fs, timeout, return_when, loop)) diff -r 6d5a76214166 -r e4fe6706b7b4 Lib/test/test_asyncio/test_tasks.py --- a/Lib/test/test_asyncio/test_tasks.py Wed Jul 16 18:36:24 2014 +0200 +++ b/Lib/test/test_asyncio/test_tasks.py Wed Jul 16 18:50:39 2014 +0200 @@ -623,10 +623,13 @@ ValueError, self.loop.run_until_complete, asyncio.wait(set(), loop=self.loop)) - self.assertRaises( - ValueError, self.loop.run_until_complete, - asyncio.wait([asyncio.sleep(10.0, loop=self.loop)], - return_when=-1, loop=self.loop)) + # -1 is an invalid return_when value + sleep_coro = asyncio.sleep(10.0, loop=self.loop) + wait_coro = asyncio.wait([sleep_coro], return_when=-1, loop=self.loop) + self.assertRaises(ValueError, + self.loop.run_until_complete, wait_coro) + + sleep_coro.close() def test_wait_first_completed(self):