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
8db3027e
Commit
8db3027e
authored
Sep 18, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #9895: speed up test_subprocess
parent
81c4d369
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
13 deletions
+32
-13
Lib/test/test_subprocess.py
Lib/test/test_subprocess.py
+32
-13
No files found.
Lib/test/test_subprocess.py
View file @
8db3027e
...
...
@@ -445,21 +445,40 @@ class ProcessTestCase(BaseTestCase):
def
test_no_leaking
(
self
):
# Make sure we leak no resources
if
(
not
hasattr
(
support
,
"is_resource_enabled"
)
or
support
.
is_resource_enabled
(
"subprocess"
)
and
not
mswindows
):
if
not
mswindows
:
max_handles
=
1026
# too much for most UNIX systems
else
:
max_handles
=
65
for
i
in
range
(
max_handles
):
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
"import sys;"
"sys.stdout.write(sys.stdin.read())"
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
data
=
p
.
communicate
(
b"lime"
)[
0
]
self
.
assertEqual
(
data
,
b"lime"
)
max_handles
=
2050
# too much for (at least some) Windows setups
handles
=
[]
try
:
for
i
in
range
(
max_handles
):
try
:
handles
.
append
(
os
.
open
(
support
.
TESTFN
,
os
.
O_WRONLY
|
os
.
O_CREAT
))
except
OSError
as
e
:
if
e
.
errno
!=
errno
.
EMFILE
:
raise
break
else
:
self
.
skipTest
(
"failed to reach the file descriptor limit "
"(tried %d)"
%
max_handles
)
# Close a couple of them (should be enough for a subprocess)
for
i
in
range
(
10
):
os
.
close
(
handles
.
pop
())
# Loop creating some subprocesses. If one of them leaks some fds,
# the next loop iteration will fail by reaching the max fd limit.
for
i
in
range
(
15
):
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
"import sys;"
"sys.stdout.write(sys.stdin.read())"
],
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
data
=
p
.
communicate
(
b"lime"
)[
0
]
self
.
assertEqual
(
data
,
b"lime"
)
finally
:
for
h
in
handles
:
os
.
close
(
h
)
def
test_list2cmdline
(
self
):
self
.
assertEqual
(
subprocess
.
list2cmdline
([
'a b c'
,
'd'
,
'e'
]),
...
...
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