MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_notify

Method test_notify

Lib/test/_test_multiprocessing.py:1615–1655  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1613 pass
1614
1615 def test_notify(self):
1616 cond = self.Condition()
1617 sleeping = self.Semaphore(0)
1618 woken = self.Semaphore(0)
1619
1620 p = self.Process(target=self.f, args=(cond, sleeping, woken))
1621 p.daemon = True
1622 p.start()
1623
1624 t = threading.Thread(target=self.f, args=(cond, sleeping, woken))
1625 t.daemon = True
1626 t.start()
1627
1628 # wait for both children to start sleeping
1629 sleeping.acquire()
1630 sleeping.acquire()
1631
1632 # check no process/thread has woken up
1633 self.assertReachesEventually(lambda: get_value(woken), 0)
1634
1635 # wake up one process/thread
1636 cond.acquire()
1637 cond.notify()
1638 cond.release()
1639
1640 # check one process/thread has woken up
1641 self.assertReachesEventually(lambda: get_value(woken), 1)
1642
1643 # wake up another
1644 cond.acquire()
1645 cond.notify()
1646 cond.release()
1647
1648 # check other has woken up
1649 self.assertReachesEventually(lambda: get_value(woken), 2)
1650
1651 # check state is not mucked up
1652 self.check_invariant(cond)
1653
1654 threading_helper.join_thread(t)
1655 join_process(p)
1656
1657 def test_notify_all(self):
1658 cond = self.Condition()

Callers

nothing calls this directly

Calls 14

startMethod · 0.95
acquireMethod · 0.95
notifyMethod · 0.95
check_invariantMethod · 0.95
join_processFunction · 0.85
SemaphoreMethod · 0.80
join_threadMethod · 0.80
get_valueFunction · 0.70
ConditionMethod · 0.45
ProcessMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected