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
075050f8
Commit
075050f8
authored
Jul 15, 2011
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_threaded_import must clean up after itself
parent
f26ad714
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
Lib/test/test_threaded_import.py
Lib/test/test_threaded_import.py
+7
-4
Lib/test/threaded_import_hangers.py
Lib/test/threaded_import_hangers.py
+9
-5
No files found.
Lib/test/test_threaded_import.py
View file @
075050f8
...
...
@@ -11,8 +11,8 @@ import sys
import
time
import
shutil
import
unittest
from
test.support
import
verbose
,
import_module
,
run_unittest
,
TESTFN
thread
=
import_module
(
'_thread'
)
from
test.support
import
(
verbose
,
import_module
,
run_unittest
,
TESTFN
,
reap_threads
)
threading
=
import_module
(
'threading'
)
def
task
(
N
,
done
,
done_tasks
,
errors
):
...
...
@@ -62,7 +62,7 @@ class Finder:
def
__init__
(
self
):
self
.
numcalls
=
0
self
.
x
=
0
self
.
lock
=
thread
.
allocate_l
ock
()
self
.
lock
=
thread
ing
.
L
ock
()
def
find_module
(
self
,
name
,
path
=
None
):
# Simulate some thread-unsafe behaviour. If calls to find_module()
...
...
@@ -113,7 +113,9 @@ class ThreadedImportTests(unittest.TestCase):
done_tasks
=
[]
done
.
clear
()
for
i
in
range
(
N
):
thread
.
start_new_thread
(
task
,
(
N
,
done
,
done_tasks
,
errors
,))
t
=
threading
.
Thread
(
target
=
task
,
args
=
(
N
,
done
,
done_tasks
,
errors
,))
t
.
start
()
done
.
wait
(
60
)
self
.
assertFalse
(
errors
)
if
verbose
:
...
...
@@ -203,6 +205,7 @@ class ThreadedImportTests(unittest.TestCase):
self
.
assertEqual
(
set
(
results
),
{
'a'
,
'b'
})
@
reap_threads
def
test_main
():
run_unittest
(
ThreadedImportTests
)
...
...
Lib/test/threaded_import_hangers.py
View file @
075050f8
...
...
@@ -35,8 +35,12 @@ for name, func, args in [
(
"os.path.abspath"
,
os
.
path
.
abspath
,
(
'.'
,)),
]:
t
=
Worker
(
func
,
args
)
t
.
start
()
t
.
join
(
TIMEOUT
)
if
t
.
is_alive
():
errors
.
append
(
"%s appeared to hang"
%
name
)
try
:
t
=
Worker
(
func
,
args
)
t
.
start
()
t
.
join
(
TIMEOUT
)
if
t
.
is_alive
():
errors
.
append
(
"%s appeared to hang"
%
name
)
finally
:
del
t
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