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

Method test_waitfor

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

Source from the content-addressed store, hash-verified

1999 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
2000 @unittest.skipUnless(HAS_SHAREDCTYPES, 'needs sharedctypes')
2001 def test_waitfor(self):
2002 # based on test in test/lock_tests.py
2003 cond = self.Condition()
2004 state = self.Value('i', -1)
2005
2006 p = self.Process(target=self._test_waitfor_f, args=(cond, state))
2007 p.daemon = True
2008 p.start()
2009
2010 with cond:
2011 result = cond.wait_for(lambda : state.value==0)
2012 self.assertTrue(result)
2013 self.assertEqual(state.value, 0)
2014
2015 for i in range(4):
2016 time.sleep(0.01)
2017 with cond:
2018 state.value += 1
2019 cond.notify()
2020
2021 join_process(p)
2022 self.assertEqual(p.exitcode, 0)
2023
2024 @classmethod
2025 def _test_waitfor_timeout_f(cls, cond, state, success, sem):

Callers

nothing calls this directly

Calls 10

wait_forMethod · 0.95
notifyMethod · 0.95
join_processFunction · 0.85
ValueMethod · 0.80
assertTrueMethod · 0.80
ConditionMethod · 0.45
ProcessMethod · 0.45
startMethod · 0.45
assertEqualMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected