asyncio: Remove Process.subprocess attribute; it's too easy to get inconsistent
authorVictor Stinner <victor.stinner@gmail.com>
Sun, 9 Feb 2014 01:51:40 +0000 (02:51 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Sun, 9 Feb 2014 01:51:40 +0000 (02:51 +0100)
Process and Popen objects

Doc/library/asyncio-subprocess.rst
Lib/asyncio/subprocess.py
Lib/test/test_asyncio/test_subprocess.py

index a2c46dc372a6339cfa378684544e6434b4316e78..5e6e657e3e498524b0904feff6ab9d123f477dca 100644 (file)
@@ -87,10 +87,6 @@ Process
       Standard error stream (read), ``None`` if the process was created with
       ``stderr=None``.
 
-   .. attribute:: subprocess
-
-      Underlying :class:`subprocess.Popen` object.
-
    .. method:: communicate(input=None)
 
       Interact with process: Send data to stdin.  Read data from stdout and
@@ -102,7 +98,7 @@ Process
       :meth:`communicate` returns a tuple ``(stdoutdata, stderrdata)``.
 
       Note that if you want to send data to the process's stdin, you need to
-      create the Popen object with ``stdin=PIPE``.  Similarly, to get anything
+      create the Process object with ``stdin=PIPE``.  Similarly, to get anything
       other than ``None`` in the result tuple, you need to give ``stdout=PIPE``
       and/or ``stderr=PIPE`` too.
 
index 3047894b3808ea5446eae3b1358e195f491ffc20..848d64f97012c810b405c67b07ad81d700f7f23b 100644 (file)
@@ -106,10 +106,6 @@ class Process:
         yield from waiter
         return waiter.result()
 
-    @property
-    def subprocess(self):
-        return self._transport.get_extra_info('subprocess')
-
     def _check_alive(self):
         if self._transport.get_returncode() is not None:
             raise ProcessLookupError()
index 785156c77fb272fdccc204b3a971f07483d4d84b..1b2f05bef28491de84635d97214638658b44b9f1 100644 (file)
@@ -7,9 +7,6 @@ from test import support
 if sys.platform != 'win32':
     from asyncio import unix_events
 
-# Program exiting quickly
-PROGRAM_EXIT_FAST = [sys.executable, '-c', 'pass']
-
 # Program blocking
 PROGRAM_BLOCKED = [sys.executable, '-c', 'import time; time.sleep(3600)']
 
@@ -119,23 +116,6 @@ class SubprocessMixin:
         returncode = self.loop.run_until_complete(proc.wait())
         self.assertEqual(-signal.SIGHUP, returncode)
 
-    def test_subprocess(self):
-        args = PROGRAM_EXIT_FAST
-
-        @asyncio.coroutine
-        def run():
-            proc = yield from asyncio.create_subprocess_exec(*args,
-                                                             loop=self.loop)
-            yield from proc.wait()
-            # need to poll subprocess.Popen, otherwise the returncode
-            # attribute is not set
-            proc.subprocess.wait()
-            return proc
-
-        proc = self.loop.run_until_complete(run())
-        self.assertEqual(proc.subprocess.returncode, proc.returncode)
-        self.assertEqual(proc.subprocess.pid, proc.pid)
-
     def test_broken_pipe(self):
         large_data = b'x' * support.PIPE_MAX_SIZE