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
b79eb050
Commit
b79eb050
authored
Feb 03, 2014
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asyncio.subprocess: Replace Process.get_subprocess() method with a
Process.subprocess read-only property
parent
cb306d1b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
27 deletions
+28
-27
Doc/library/asyncio-subprocess.rst
Doc/library/asyncio-subprocess.rst
+17
-17
Lib/asyncio/subprocess.py
Lib/asyncio/subprocess.py
+2
-1
Lib/test/test_asyncio/test_subprocess.py
Lib/test/test_asyncio/test_subprocess.py
+9
-9
No files found.
Doc/library/asyncio-subprocess.rst
View file @
b79eb050
...
...
@@ -57,6 +57,21 @@ Process
.. class:: asyncio.subprocess.Process
.. attribute:: pid
The identifier of the process.
Note that if you set the *shell* argument to ``True``, this is the
process identifier of the spawned shell.
.. attribute:: returncode
Return code of the process when it exited. A ``None`` value indicates
that the process has not terminated yet.
A negative value ``-N`` indicates that the child was terminated by signal
``N`` (Unix only).
.. attribute:: stdin
Standard input stream (write), ``None`` if the process was created with
...
...
@@ -72,20 +87,9 @@ Process
Standard error stream (read), ``None`` if the process was created with
``stderr=None``.
.. attribute:: pid
The identifier of the process.
Note that if you set the *shell* argument to ``True``, this is the
process identifier of the spawned shell.
.. attribute:: subprocess
.. attribute:: returncode
Return code of the process when it exited. A ``None`` value indicates
that the process has not terminated yet.
A negative value ``-N`` indicates that the child was terminated by signal
``N`` (Unix only).
Underlying :class:`subprocess.Popen` object.
.. method:: communicate(input=None)
...
...
@@ -107,10 +111,6 @@ Process
The data read is buffered in memory, so do not use this method if the
data size is large or unlimited.
.. method:: get_subprocess()
Get the underlying :class:`subprocess.Popen` object.
.. method:: kill()
Kills the child. On Posix OSs the function sends :py:data:`SIGKILL` to
...
...
Lib/asyncio/subprocess.py
View file @
b79eb050
...
...
@@ -106,7 +106,8 @@ class Process:
yield
from
waiter
return
waiter
.
result
()
def
get_subprocess
(
self
):
@
property
def
subprocess
(
self
):
return
self
.
_transport
.
get_extra_info
(
'subprocess'
)
def
_check_alive
(
self
):
...
...
Lib/test/test_asyncio/test_subprocess.py
View file @
b79eb050
...
...
@@ -119,7 +119,7 @@ class SubprocessMixin:
returncode
=
self
.
loop
.
run_until_complete
(
proc
.
wait
())
self
.
assertEqual
(
-
signal
.
SIGHUP
,
returncode
)
def
test_
get_
subprocess
(
self
):
def
test_subprocess
(
self
):
args
=
PROGRAM_EXIT_FAST
@
asyncio
.
coroutine
...
...
@@ -127,14 +127,14 @@ class SubprocessMixin:
proc
=
yield
from
asyncio
.
create_subprocess_exec
(
*
args
,
loop
=
self
.
loop
)
yield
from
proc
.
wait
()
popen
=
proc
.
get_subprocess
()
p
open
.
wait
()
return
(
proc
,
popen
)
proc
,
popen
=
self
.
loop
.
run_until_complete
(
run
())
self
.
assertEqual
(
p
open
.
returncode
,
proc
.
returncode
)
self
.
assertEqual
(
p
open
.
pid
,
proc
.
pid
)
# need to poll subprocess.Popen, otherwise the returncode
# attribute is not set
p
roc
.
subprocess
.
wait
()
return
proc
proc
=
self
.
loop
.
run_until_complete
(
run
())
self
.
assertEqual
(
p
roc
.
subprocess
.
returncode
,
proc
.
returncode
)
self
.
assertEqual
(
p
roc
.
subprocess
.
pid
,
proc
.
pid
)
def
test_broken_pipe
(
self
):
large_data
=
b'x'
*
support
.
PIPE_MAX_SIZE
...
...
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