(self)
| 2008 | pass |
| 2009 | |
| 2010 | def test_need_for_rlock(self): |
| 2011 | # This will deadlock on an LRU cache that uses a regular lock |
| 2012 | |
| 2013 | @self.module.lru_cache(maxsize=10) |
| 2014 | def test_func(x): |
| 2015 | 'Used to demonstrate a reentrant lru_cache call within a single thread' |
| 2016 | return x |
| 2017 | |
| 2018 | class DoubleEq: |
| 2019 | 'Demonstrate a reentrant lru_cache call within a single thread' |
| 2020 | def __init__(self, x): |
| 2021 | self.x = x |
| 2022 | def __hash__(self): |
| 2023 | return self.x |
| 2024 | def __eq__(self, other): |
| 2025 | if self.x == 2: |
| 2026 | test_func(DoubleEq(1)) |
| 2027 | return self.x == other.x |
| 2028 | |
| 2029 | test_func(DoubleEq(1)) # Load the cache |
| 2030 | test_func(DoubleEq(2)) # Load the cache |
| 2031 | self.assertEqual(test_func(DoubleEq(2)), # Trigger a re-entrant __eq__ call |
| 2032 | DoubleEq(2)) # Verify the correct return value |
| 2033 | |
| 2034 | def test_lru_method(self): |
| 2035 | class X(int): |
nothing calls this directly
no test coverage detected