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

Method test_BoundedSemaphore_limit

Lib/test/test_threading.py:995–1011  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

993 t.join()
994
995 def test_BoundedSemaphore_limit(self):
996 # BoundedSemaphore should raise ValueError if released too often.
997 for limit in range(1, 10):
998 bs = threading.BoundedSemaphore(limit)
999 threads = [threading.Thread(target=bs.acquire)
1000 for _ in range(limit)]
1001 for t in threads:
1002 t.start()
1003 for t in threads:
1004 t.join()
1005 threads = [threading.Thread(target=bs.release)
1006 for _ in range(limit)]
1007 for t in threads:
1008 t.start()
1009 for t in threads:
1010 t.join()
1011 self.assertRaises(ValueError, bs.release)
1012
1013 @cpython_only
1014 def test_frame_tstate_tracing(self):

Callers

nothing calls this directly

Calls 4

BoundedSemaphoreMethod · 0.80
startMethod · 0.45
joinMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected