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
c091a576
Commit
c091a576
authored
Dec 13, 2013
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19704: Port test.test_threaded_import to PEP 451
parent
706a7296
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
Lib/test/test_threaded_import.py
Lib/test/test_threaded_import.py
+6
-6
No files found.
Lib/test/test_threaded_import.py
View file @
c091a576
...
...
@@ -57,7 +57,7 @@ circular_imports_modules = {
}
class
Finder
:
"""A dummy finder to detect concurrent access to its find_
module
()
"""A dummy finder to detect concurrent access to its find_
spec
()
method."""
def
__init__
(
self
):
...
...
@@ -65,8 +65,8 @@ class Finder:
self
.
x
=
0
self
.
lock
=
threading
.
Lock
()
def
find_
module
(
self
,
name
,
path
=
None
):
# Simulate some thread-unsafe behaviour. If calls to find_
module
()
def
find_
spec
(
self
,
name
,
path
=
None
,
target
=
None
):
# Simulate some thread-unsafe behaviour. If calls to find_
spec
()
# are properly serialized, `x` will end up the same as `numcalls`.
# Otherwise not.
assert
imp
.
lock_held
()
...
...
@@ -80,7 +80,7 @@ class FlushingFinder:
"""A dummy finder which flushes sys.path_importer_cache when it gets
called."""
def
find_
module
(
self
,
name
,
path
=
None
):
def
find_
spec
(
self
,
name
,
path
=
None
,
target
=
None
):
sys
.
path_importer_cache
.
clear
()
...
...
@@ -145,13 +145,13 @@ class ThreadedImportTests(unittest.TestCase):
# dedicated meta_path entry.
flushing_finder
=
FlushingFinder
()
def
path_hook
(
path
):
finder
.
find_
module
(
''
)
finder
.
find_
spec
(
''
)
raise
ImportError
sys
.
path_hooks
.
insert
(
0
,
path_hook
)
sys
.
meta_path
.
append
(
flushing_finder
)
try
:
# Flush the cache a first time
flushing_finder
.
find_
module
(
''
)
flushing_finder
.
find_
spec
(
''
)
numtests
=
self
.
check_parallel_module_init
()
self
.
assertGreater
(
finder
.
numcalls
,
0
)
self
.
assertEqual
(
finder
.
x
,
finder
.
numcalls
)
...
...
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