Repeatly access the memoryview for racing.
(self)
| 866 | @support.requires_resource("cpu") |
| 867 | class 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 | |
| 893 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected