def test_double_close(self): channel = Channel(1, loop=self.loop) self.assertFalse(channel.closed()) channel.close() self.assertTrue(channel.closed()) channel.close() self.assertTrue(channel.closed())
def test_put_throws_channel_closed(self): """ Test that when a put blocks, and a channel is closed, the put will throw a ChannelClosed instead of waiting to add to channel """ channel = Channel(1, loop=self.loop) channel.put_nowait("foo") self.assertTrue(channel.full()) @asyncio.coroutine def wait_close(): yield from asyncio.sleep(0.01, loop=self.loop) channel.close() (put_return, _) = self.rucgather(channel.put("bar"), wait_close(), return_exceptions=True) self.assertIsInstance(put_return, ChannelClosed) self.assertTrue(channel.closed())