(self)
| 1968 | |
| 1969 | @threading_helper.requires_working_threading() |
| 1970 | def test_lru_cache_threaded2(self): |
| 1971 | # Simultaneous call with the same arguments |
| 1972 | n, m = 5, 7 |
| 1973 | start = threading.Barrier(n+1) |
| 1974 | pause = threading.Barrier(n+1) |
| 1975 | stop = threading.Barrier(n+1) |
| 1976 | @self.module.lru_cache(maxsize=m*n) |
| 1977 | def f(x): |
| 1978 | pause.wait(10) |
| 1979 | return 3 * x |
| 1980 | self.assertEqual(f.cache_info(), (0, 0, m*n, 0)) |
| 1981 | def test(): |
| 1982 | for i in range(m): |
| 1983 | start.wait(10) |
| 1984 | self.assertEqual(f(i), 3 * i) |
| 1985 | stop.wait(10) |
| 1986 | threads = [threading.Thread(target=test) for k in range(n)] |
| 1987 | with threading_helper.start_threads(threads): |
| 1988 | for i in range(m): |
| 1989 | start.wait(10) |
| 1990 | stop.reset() |
| 1991 | pause.wait(10) |
| 1992 | start.reset() |
| 1993 | stop.wait(10) |
| 1994 | pause.reset() |
| 1995 | self.assertEqual(f.cache_info(), (0, (i+1)*n, m*n, i+1)) |
| 1996 | |
| 1997 | @threading_helper.requires_working_threading() |
| 1998 | def test_lru_cache_threaded3(self): |
nothing calls this directly
no test coverage detected