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

Method test_notify

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

Source from the content-addressed store, hash-verified

1811
1812 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
1813 def test_notify(self):
1814 cond = self.Condition()
1815 sleeping = self.Semaphore(0)
1816 woken = self.Semaphore(0)
1817
1818 p = self.Process(target=self.f, args=(cond, sleeping, woken))
1819 p.daemon = True
1820 p.start()
1821
1822 t = threading.Thread(target=self.f, args=(cond, sleeping, woken))
1823 t.daemon = True
1824 t.start()
1825
1826 # wait for both children to start sleeping
1827 sleeping.acquire()
1828 sleeping.acquire()
1829
1830 # check no process/thread has woken up
1831 self.assertReachesEventually(lambda: get_value(woken), 0)
1832
1833 # wake up one process/thread
1834 cond.acquire()
1835 cond.notify()
1836 cond.release()
1837
1838 # check one process/thread has woken up
1839 self.assertReachesEventually(lambda: get_value(woken), 1)
1840
1841 # wake up another
1842 cond.acquire()
1843 cond.notify()
1844 cond.release()
1845
1846 # check other has woken up
1847 self.assertReachesEventually(lambda: get_value(woken), 2)
1848
1849 # check state is not mucked up
1850 self.check_invariant(cond)
1851
1852 threading_helper.join_thread(t)
1853 join_process(p)
1854
1855 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
1856 def test_notify_all(self):

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