(self)
| 1190 | sleep_coro.close() |
| 1191 | |
| 1192 | def test_wait_first_completed(self): |
| 1193 | |
| 1194 | def gen(): |
| 1195 | when = yield |
| 1196 | self.assertAlmostEqual(10.0, when) |
| 1197 | when = yield 0 |
| 1198 | self.assertAlmostEqual(0.1, when) |
| 1199 | yield 0.1 |
| 1200 | |
| 1201 | loop = self.new_test_loop(gen) |
| 1202 | |
| 1203 | a = self.new_task(loop, asyncio.sleep(10.0)) |
| 1204 | b = self.new_task(loop, asyncio.sleep(0.1)) |
| 1205 | task = self.new_task( |
| 1206 | loop, |
| 1207 | asyncio.wait([b, a], return_when=asyncio.FIRST_COMPLETED)) |
| 1208 | |
| 1209 | done, pending = loop.run_until_complete(task) |
| 1210 | self.assertEqual({b}, done) |
| 1211 | self.assertEqual({a}, pending) |
| 1212 | self.assertFalse(a.done()) |
| 1213 | self.assertTrue(b.done()) |
| 1214 | self.assertIsNone(b.result()) |
| 1215 | self.assertAlmostEqual(0.1, loop.time()) |
| 1216 | |
| 1217 | # move forward to close generator |
| 1218 | loop.advance_time(10) |
| 1219 | loop.run_until_complete(asyncio.wait([a, b])) |
| 1220 | |
| 1221 | def test_wait_really_done(self): |
| 1222 | # there is possibility that some tasks in the pending list |
nothing calls this directly
no test coverage detected