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

Method test_waitfor_timeout

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

Source from the content-addressed store, hash-verified

2035 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
2036 @unittest.skipUnless(HAS_SHAREDCTYPES, 'needs sharedctypes')
2037 def test_waitfor_timeout(self):
2038 # based on test in test/lock_tests.py
2039 cond = self.Condition()
2040 state = self.Value('i', 0)
2041 success = self.Value('i', False)
2042 sem = self.Semaphore(0)
2043
2044 p = self.Process(target=self._test_waitfor_timeout_f,
2045 args=(cond, state, success, sem))
2046 p.daemon = True
2047 p.start()
2048 self.assertTrue(sem.acquire(timeout=support.LONG_TIMEOUT))
2049
2050 # Only increment 3 times, so state == 4 is never reached.
2051 for i in range(3):
2052 time.sleep(0.010)
2053 with cond:
2054 state.value += 1
2055 cond.notify()
2056
2057 join_process(p)
2058 self.assertTrue(success.value)
2059
2060 @classmethod
2061 def _test_wait_result(cls, c, pid):

Callers

nothing calls this directly

Calls 10

acquireMethod · 0.95
notifyMethod · 0.95
join_processFunction · 0.85
ValueMethod · 0.80
SemaphoreMethod · 0.80
assertTrueMethod · 0.80
ConditionMethod · 0.45
ProcessMethod · 0.45
startMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected