(self)
| 2039 | pass |
| 2040 | |
| 2041 | def test_need_for_rlock(self): |
| 2042 | # This will deadlock on an LRU cache that uses a regular lock |
| 2043 | |
| 2044 | @self.module.lru_cache(maxsize=10) |
| 2045 | def test_func(x): |
| 2046 | 'Used to demonstrate a reentrant lru_cache call within a single thread' |
| 2047 | return x |
| 2048 | |
| 2049 | class DoubleEq: |
| 2050 | 'Demonstrate a reentrant lru_cache call within a single thread' |
| 2051 | def __init__(self, x): |
| 2052 | self.x = x |
| 2053 | def __hash__(self): |
| 2054 | return self.x |
| 2055 | def __eq__(self, other): |
| 2056 | if self.x == 2: |
| 2057 | test_func(DoubleEq(1)) |
| 2058 | return self.x == other.x |
| 2059 | |
| 2060 | test_func(DoubleEq(1)) # Load the cache |
| 2061 | test_func(DoubleEq(2)) # Load the cache |
| 2062 | self.assertEqual(test_func(DoubleEq(2)), # Trigger a re-entrant __eq__ call |
| 2063 | DoubleEq(2)) # Verify the correct return value |
| 2064 | |
| 2065 | def test_lru_method(self): |
| 2066 | class X(int): |
nothing calls this directly
no test coverage detected