MCPcopy Create free account
hub / github.com/python/cpython / test_put_cancelled_race

Method test_put_cancelled_race

Lib/test/test_asyncio/test_queues.py:350–368  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

348 self.assertTrue(t.result())
349
350 async def test_put_cancelled_race(self):
351 q = asyncio.Queue(maxsize=1)
352
353 put_a = asyncio.create_task(q.put('a'))
354 put_b = asyncio.create_task(q.put('b'))
355 put_c = asyncio.create_task(q.put('X'))
356
357 await asyncio.sleep(0)
358 self.assertTrue(put_a.done())
359 self.assertFalse(put_b.done())
360
361 put_c.cancel()
362 await asyncio.sleep(0)
363 self.assertTrue(put_c.done())
364 self.assertEqual(q.get_nowait(), 'a')
365 await asyncio.sleep(0)
366 self.assertEqual(q.get_nowait(), 'b')
367
368 await put_b
369
370 async def test_put_with_waiting_getters(self):
371 q = asyncio.Queue()

Callers

nothing calls this directly

Calls 10

putMethod · 0.95
get_nowaitMethod · 0.95
QueueMethod · 0.80
assertTrueMethod · 0.80
assertFalseMethod · 0.80
create_taskMethod · 0.45
sleepMethod · 0.45
doneMethod · 0.45
cancelMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected