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

Method test_notify_all

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 14

startMethod · 0.95
acquireMethod · 0.95
check_invariantMethod · 0.95
notify_allMethod · 0.95
SemaphoreMethod · 0.80
join_threadMethod · 0.80
ConditionMethod · 0.45
ProcessMethod · 0.45
startMethod · 0.45
appendMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected