MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_reacquire

Method test_reacquire

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

start_new_threadFunction · 0.90
wait_phaseMethod · 0.80
releaseMethod · 0.45

Tested by

no test coverage detected