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

Method test_reacquire

Lib/test/lock_tests.py:275–293  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

273 (which can be acquired and released from different threads).
274 """
275 def test_reacquire(self):
276 # Lock needs to be released before re-acquiring.
277 lock = self.locktype()
278 phase = []
279
280 def f():
281 lock.acquire()
282 phase.append(None)
283 lock.acquire()
284 phase.append(None)
285
286 with threading_helper.wait_threads_exit():
287 # Thread blocked on lock.acquire()
288 start_new_thread(f, ())
289 self.wait_phase(phase, 1)
290
291 # Thread unblocked
292 lock.release()
293 self.wait_phase(phase, 2)
294
295 def test_different_thread(self):
296 # Lock can be released from a different thread.

Callers

nothing calls this directly

Calls 2

wait_phaseMethod · 0.80
releaseMethod · 0.45

Tested by

no test coverage detected