Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
03923426
Commit
03923426
authored
Mar 04, 2013
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for RLock in the lru_cache().
parent
ad246bfb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
Lib/test/test_functools.py
Lib/test/test_functools.py
+25
-0
No files found.
Lib/test/test_functools.py
View file @
03923426
...
...
@@ -777,6 +777,31 @@ class TestLRU(unittest.TestCase):
self
.
assertEqual
(
square
.
cache_info
().
hits
,
4
)
self
.
assertEqual
(
square
.
cache_info
().
misses
,
4
)
def
test_need_for_rlock
(
self
):
# This will deadlock on an LRU cache that uses a regular lock
@
functools
.
lru_cache
(
maxsize
=
10
)
def
test_func
(
x
):
'Used to demonstrate a reentrant lru_cache call within a single thread'
return
x
class
DoubleEq
:
'Demonstrate a reentrant lru_cache call within a single thread'
def
__init__
(
self
,
x
):
self
.
x
=
x
def
__hash__
(
self
):
return
self
.
x
def
__eq__
(
self
,
other
):
if
self
.
x
==
2
:
test_func
(
DoubleEq
(
1
))
return
self
.
x
==
other
.
x
test_func
(
DoubleEq
(
1
))
# Load the cache
test_func
(
DoubleEq
(
2
))
# Load the cache
self
.
assertEqual
(
test_func
(
DoubleEq
(
2
)),
# Trigger a re-entrant __eq__ call
DoubleEq
(
2
))
# Verify the correct return value
def
test_main
(
verbose
=
None
):
test_classes
=
(
TestPartial
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment