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
c447ba04
Commit
c447ba04
authored
Jan 06, 2015
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #23140, asyncio: Fix cancellation of Process.wait(). Check the state of
the waiter future before setting its result.
parent
8c1a4a23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
Lib/asyncio/subprocess.py
Lib/asyncio/subprocess.py
+2
-1
Lib/test/test_asyncio/test_subprocess.py
Lib/test/test_asyncio/test_subprocess.py
+28
-0
No files found.
Lib/asyncio/subprocess.py
View file @
c447ba04
...
...
@@ -96,7 +96,8 @@ class SubprocessStreamProtocol(streams.FlowControlMixin,
returncode
=
self
.
_transport
.
get_returncode
()
while
self
.
_waiters
:
waiter
=
self
.
_waiters
.
popleft
()
waiter
.
set_result
(
returncode
)
if
not
waiter
.
cancelled
():
waiter
.
set_result
(
returncode
)
class
Process
:
...
...
Lib/test/test_asyncio/test_subprocess.py
View file @
c447ba04
...
...
@@ -223,6 +223,34 @@ class SubprocessMixin:
self
.
assertEqual
(
output
.
rstrip
(),
b'3'
)
self
.
assertEqual
(
exitcode
,
0
)
def
test_cancel_process_wait
(
self
):
# Issue #23140: cancel Process.wait()
@
asyncio
.
coroutine
def
wait_proc
(
proc
,
event
):
event
.
set
()
yield
from
proc
.
wait
()
@
asyncio
.
coroutine
def
cancel_wait
():
proc
=
yield
from
asyncio
.
create_subprocess_exec
(
*
PROGRAM_BLOCKED
,
loop
=
self
.
loop
)
# Create an internal future waiting on the process exit
event
=
asyncio
.
Event
(
loop
=
self
.
loop
)
task
=
self
.
loop
.
create_task
(
wait_proc
(
proc
,
event
))
yield
from
event
.
wait
()
# Cancel the future
task
.
cancel
()
# Kill the process and wait until it is done
proc
.
kill
()
yield
from
proc
.
wait
()
self
.
loop
.
run_until_complete
(
cancel_wait
())
if
sys
.
platform
!=
'win32'
:
# Unix
...
...
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