MCPcopy Index your code
hub / github.com/python/cpython / test_notify_all

Method test_notify_all

Lib/test/test_asyncio/test_locks.py:624–658  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

622 self.assertTrue(t3.result())
623
624 async def test_notify_all(self):
625 cond = asyncio.Condition()
626
627 result = []
628
629 async def c1(result):
630 await cond.acquire()
631 if await cond.wait():
632 result.append(1)
633 cond.release()
634 return True
635
636 async def c2(result):
637 await cond.acquire()
638 if await cond.wait():
639 result.append(2)
640 cond.release()
641 return True
642
643 t1 = asyncio.create_task(c1(result))
644 t2 = asyncio.create_task(c2(result))
645
646 await asyncio.sleep(0)
647 self.assertEqual([], result)
648
649 await cond.acquire()
650 cond.notify_all()
651 cond.release()
652 await asyncio.sleep(0)
653 self.assertEqual([1, 2], result)
654
655 self.assertTrue(t1.done())
656 self.assertTrue(t1.result())
657 self.assertTrue(t2.done())
658 self.assertTrue(t2.result())
659
660 def test_notify_unacquired(self):
661 cond = asyncio.Condition()

Callers

nothing calls this directly

Calls 10

notify_allMethod · 0.95
assertTrueMethod · 0.80
ConditionMethod · 0.45
create_taskMethod · 0.45
sleepMethod · 0.45
assertEqualMethod · 0.45
acquireMethod · 0.45
releaseMethod · 0.45
doneMethod · 0.45
resultMethod · 0.45

Tested by

no test coverage detected