(self)
| 1854 | |
| 1855 | @warnings_helper.ignore_fork_in_thread_deprecation_warnings() |
| 1856 | def test_notify_all(self): |
| 1857 | cond = self.Condition() |
| 1858 | sleeping = self.Semaphore(0) |
| 1859 | woken = self.Semaphore(0) |
| 1860 | |
| 1861 | # start some threads/processes which will timeout |
| 1862 | workers = [] |
| 1863 | for i in range(3): |
| 1864 | p = self.Process(target=self.f, |
| 1865 | args=(cond, sleeping, woken, TIMEOUT1)) |
| 1866 | p.daemon = True |
| 1867 | p.start() |
| 1868 | workers.append(p) |
| 1869 | |
| 1870 | t = threading.Thread(target=self.f, |
| 1871 | args=(cond, sleeping, woken, TIMEOUT1)) |
| 1872 | t.daemon = True |
| 1873 | t.start() |
| 1874 | workers.append(t) |
| 1875 | |
| 1876 | # wait for them all to sleep |
| 1877 | for i in range(6): |
| 1878 | sleeping.acquire() |
| 1879 | |
| 1880 | # check they have all timed out |
| 1881 | for i in range(6): |
| 1882 | woken.acquire() |
| 1883 | self.assertReturnsIfImplemented(0, get_value, woken) |
| 1884 | |
| 1885 | # check state is not mucked up |
| 1886 | self.check_invariant(cond) |
| 1887 | |
| 1888 | # start some more threads/processes |
| 1889 | for i in range(3): |
| 1890 | p = self.Process(target=self.f, args=(cond, sleeping, woken)) |
| 1891 | p.daemon = True |
| 1892 | p.start() |
| 1893 | workers.append(p) |
| 1894 | |
| 1895 | t = threading.Thread(target=self.f, args=(cond, sleeping, woken)) |
| 1896 | t.daemon = True |
| 1897 | t.start() |
| 1898 | workers.append(t) |
| 1899 | |
| 1900 | # wait for them to all sleep |
| 1901 | for i in range(6): |
| 1902 | sleeping.acquire() |
| 1903 | |
| 1904 | # check no process/thread has woken up |
| 1905 | time.sleep(DELTA) |
| 1906 | self.assertReturnsIfImplemented(0, get_value, woken) |
| 1907 | |
| 1908 | # wake them all up |
| 1909 | cond.acquire() |
| 1910 | cond.notify_all() |
| 1911 | cond.release() |
| 1912 | |
| 1913 | # check they have all woken |
nothing calls this directly
no test coverage detected