def test_put_cancel_drop(self):

    def gen():
        (yield 0.01)
        (yield 0.1)
    loop = self.new_test_loop(gen)
    q = asyncio.Queue(1, loop=loop)
    q.put_nowait(1)
    writer = loop.create_task(q.put(2))
    loop.run_until_complete(asyncio.sleep(0.01, loop=loop))
    value1 = q.get_nowait()
    self.assertEqual(value1, 1)
    writer.cancel()
    try:
        loop.run_until_complete(writer)
    except asyncio.CancelledError:
        writer = loop.create_task(q.put(2))
        loop.run_until_complete(writer)
    value2 = q.get_nowait()
    self.assertEqual(value2, 2)
    self.assertEqual(q.qsize(), 0)
def test_put_cancel_drop(self):

    def gen():
        (yield 0.01)
        (yield 0.1)
    loop = self.new_test_loop(gen)
    q = asyncio.Queue(1, loop=loop)
    q.put_nowait(1)
    writer = loop.create_task(q.put(2))
    loop.run_until_complete(asyncio.sleep(0.01, loop=loop))
    value1 = q.get_nowait()
    self.assertEqual(value1, 1)
    writer.cancel()
    try:
        loop.run_until_complete(writer)
    except asyncio.CancelledError:
        writer = loop.create_task(q.put(2))
        loop.run_until_complete(writer)
    value2 = q.get_nowait()
    self.assertEqual(value2, 2)
    self.assertEqual(q.qsize(), 0)