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
a4024e2d
Commit
a4024e2d
authored
Sep 24, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make _kill_process more robust under Windows too (see issue #8432)
parent
ff09ce21
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
20 deletions
+14
-20
Lib/test/test_subprocess.py
Lib/test/test_subprocess.py
+14
-20
No files found.
Lib/test/test_subprocess.py
View file @
a4024e2d
...
@@ -1000,28 +1000,22 @@ class Win32ProcessTestCase(BaseTestCase):
...
@@ -1000,28 +1000,22 @@ class Win32ProcessTestCase(BaseTestCase):
def
_kill_process
(
self
,
method
,
*
args
):
def
_kill_process
(
self
,
method
,
*
args
):
# Some win32 buildbot raises EOFError if stdin is inherited
# Some win32 buildbot raises EOFError if stdin is inherited
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
"input()"
],
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
"""if 1:
stdin
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
import sys, time
sys.stdout.write('x
\
\
n')
# Let the process initialize (Issue #3137)
sys.stdout.flush()
time
.
sleep
(
0.1
)
time.sleep(30)
# The process should not terminate prematurely
"""
],
self
.
assertIsNone
(
p
.
poll
())
stdin
=
subprocess
.
PIPE
,
# Retry if the process do not receive the signal.
stdout
=
subprocess
.
PIPE
,
count
,
maxcount
=
0
,
3
stderr
=
subprocess
.
PIPE
)
while
count
<
maxcount
and
p
.
poll
()
is
None
:
# Wait for the interpreter to be completely initialized before
getattr
(
p
,
method
)(
*
args
)
# sending any signal.
time
.
sleep
(
0.1
)
p
.
stdout
.
read
(
1
)
count
+=
1
getattr
(
p
,
method
)(
*
args
)
returncode
=
p
.
poll
()
self
.
assertIsNotNone
(
returncode
,
"the subprocess did not terminate"
)
if
count
>
1
:
print
(
"p.{}{} succeeded after "
"{} attempts"
.
format
(
method
,
args
,
count
),
file
=
sys
.
stderr
)
_
,
stderr
=
p
.
communicate
()
_
,
stderr
=
p
.
communicate
()
self
.
assertStderrEqual
(
stderr
,
b''
)
self
.
assertStderrEqual
(
stderr
,
b''
)
self
.
assertEqual
(
p
.
wait
(),
returncode
)
returncode
=
p
.
wait
(
)
self
.
assertNotEqual
(
returncode
,
0
)
self
.
assertNotEqual
(
returncode
,
0
)
def
test_send_signal
(
self
):
def
test_send_signal
(
self
):
...
...
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