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
0db3cd67
Commit
0db3cd67
authored
May 14, 2009
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a useful decorator for cleaning up threads
parent
92d102bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
Lib/test/test_hashlib.py
Lib/test/test_hashlib.py
+2
-7
Lib/test/test_support.py
Lib/test/test_support.py
+11
-0
No files found.
Lib/test/test_hashlib.py
View file @
0db3cd67
...
...
@@ -254,14 +254,9 @@ class HashLibTestCase(unittest.TestCase):
self
.
assertEqual
(
expected_hash
,
hasher
.
hexdigest
())
@
test_support
.
reap_threads
def
test_main
():
key
=
test_support
.
threading_setup
()
try
:
test_support
.
run_unittest
(
HashLibTestCase
)
finally
:
test_support
.
threading_cleanup
(
*
key
)
test_support
.
run_unittest
(
HashLibTestCase
)
if
__name__
==
"__main__"
:
test_main
()
Lib/test/test_support.py
View file @
0db3cd67
...
...
@@ -5,6 +5,7 @@ if __name__ != 'test.test_support':
import
contextlib
import
errno
import
functools
import
socket
import
sys
import
os
...
...
@@ -934,6 +935,16 @@ def threading_cleanup(num_active, num_limbo):
count
+=
1
time
.
sleep
(
0.1
)
def
reap_threads
(
func
):
@
functools
.
wraps
(
func
)
def
decorator
(
*
args
):
key
=
threading_setup
()
try
:
return
func
(
*
args
)
finally
:
threading_cleanup
(
*
key
)
return
decorator
def
reap_children
():
"""Use this function at the end of test_main() whenever sub-processes
are started. This will help ensure that no extra children (zombies)
...
...
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