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

Method test_racing_getbuf_and_releasebuf

Lib/test/test_memoryview.py:868–890  ·  view source on GitHub ↗

Repeatly access the memoryview for racing.

(self)

Source from the content-addressed store, hash-verified

866@support.requires_resource("cpu")
867class RacingTest(unittest.TestCase):
868 def test_racing_getbuf_and_releasebuf(self):
869 """Repeatly access the memoryview for racing."""
870 try:
871 from multiprocessing.managers import SharedMemoryManager
872 except ImportError:
873 self.skipTest("Test requires multiprocessing")
874 from threading import Thread, Event
875
876 start = Event()
877 with SharedMemoryManager() as smm:
878 obj = smm.ShareableList(range(100))
879 def test():
880 # Issue gh-127085, the `ShareableList.count` is just a
881 # convenient way to mess the `exports` counter of `memoryview`,
882 # this issue has no direct relation with `ShareableList`.
883 start.wait(support.SHORT_TIMEOUT)
884 for i in range(10):
885 obj.count(1)
886 threads = [Thread(target=test) for _ in range(10)]
887 with threading_helper.start_threads(threads):
888 start.set()
889
890 del obj
891
892
893if __name__ == "__main__":

Callers

nothing calls this directly

Calls 6

setMethod · 0.95
EventClass · 0.90
SharedMemoryManagerClass · 0.90
ThreadClass · 0.90
skipTestMethod · 0.80
ShareableListMethod · 0.80

Tested by

no test coverage detected