def test_put_cancelled_race(self):
    q = asyncio.Queue(loop=self.loop, maxsize=1)
    put_a = asyncio.Task(q.put('a'), loop=self.loop)
    put_b = asyncio.Task(q.put('b'), loop=self.loop)
    put_c = asyncio.Task(q.put('X'), loop=self.loop)
    test_utils.run_briefly(self.loop)
    self.assertTrue(put_a.done())
    self.assertFalse(put_b.done())
    put_c.cancel()
    test_utils.run_briefly(self.loop)
    self.assertTrue(put_c.done())
    self.assertEqual(q.get_nowait(), 'a')
    test_utils.run_briefly(self.loop)
    self.assertEqual(q.get_nowait(), 'b')
    self.loop.run_until_complete(put_b)
def test_put_cancelled_race(self):
    q = asyncio.Queue(loop=self.loop, maxsize=1)
    put_a = asyncio.Task(q.put('a'), loop=self.loop)
    put_b = asyncio.Task(q.put('b'), loop=self.loop)
    put_c = asyncio.Task(q.put('X'), loop=self.loop)
    test_utils.run_briefly(self.loop)
    self.assertTrue(put_a.done())
    self.assertFalse(put_b.done())
    put_c.cancel()
    test_utils.run_briefly(self.loop)
    self.assertTrue(put_c.done())
    self.assertEqual(q.get_nowait(), 'a')
    test_utils.run_briefly(self.loop)
    self.assertEqual(q.get_nowait(), 'b')
    self.loop.run_until_complete(put_b)