Exemplo n.º 1
0
    async def test_close_with_pending_get(self):
        channel = AsyncChannel()
        with self.assertRaises(StopAsyncIteration):
            get, close = await asyncio.gather(anext(channel),
                                              momentarily(1, channel.close()))

        with self.assertRaises(StopAsyncIteration):
            await anext(channel)
        with self.assertRaises(ValueError):
            await channel.put('foo')
Exemplo n.º 2
0
    async def test_close_with_pending_get(self):
        channel = AsyncChannel()
        with self.assertRaises(StopAsyncIteration):
            get, close = await asyncio.gather(
                    anext(channel),
                    momentarily(1, channel.close()))

        with self.assertRaises(StopAsyncIteration):
            await anext(channel)
        with self.assertRaises(ValueError):
            await channel.put('foo')
Exemplo n.º 3
0
    async def test_close_with_pending_put(self):
        channel = AsyncChannel()
        put, close, get = await asyncio.gather(channel.put('foo'),
                                               momentarily(1, channel.close()),
                                               momentarily(2, anext(channel)))
        self.assertIsNone(put)
        self.assertIsNone(close)
        self.assertEqual(get, 'foo')

        with self.assertRaises(StopAsyncIteration):
            await anext(channel)
        with self.assertRaises(ValueError):
            await channel.put('foo')
Exemplo n.º 4
0
    async def test_close_with_pending_put(self):
        channel = AsyncChannel()
        put, close, get = await asyncio.gather(
                channel.put('foo'),
                momentarily(1, channel.close()),
                momentarily(2, anext(channel)))
        self.assertIsNone(put)
        self.assertIsNone(close)
        self.assertEqual(get, 'foo')

        with self.assertRaises(StopAsyncIteration):
            await anext(channel)
        with self.assertRaises(ValueError):
            await channel.put('foo')