vomebook commited on
Commit ·
775dc9e
1
Parent(s): 2390b8f
Bound closed proxy subscription test before cancellation
Browse files156 unmodified lines157158159160161162163156 unmodified linessubscriber = RangeSubscription(flight)subscriber.closed = Trueflight.chunks.append(b'must not leak')self.assertEqual([chunk async for chunk in subscriber.stream()], [])self.assertTrue(flight.started.is_set())self.assertIsNone(subscriber.flight)156 unmodified lines157158159160161162163164165166167168169170171172173174175176156 unmodified linessubscriber = RangeSubscription(flight)subscriber.closed = Trueflight.chunks.append(b'must not leak')async def collect():return [chunk async for chunk in subscriber.stream()]task = asyncio.create_task(collect())try:done, _ = await asyncio.wait({task}, timeout=1)# Check before cancellation: the stream may suppress CancelledError.self.assertIn(task, done, 'closed subscriber stream did not finish within 1 second')self.assertEqual(task.result(), [])finally:if not task.done():task.cancel()await asyncio.gather(task, return_exceptions=True)self.assertTrue(flight.started.is_set())self.assertIsNone(subscriber.flight)
tests/proxy/test_proxy_streams_contract.py+14-1