(self)
| 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): |
nothing calls this directly
no test coverage detected