[Python-checkins] cpython (3.4): Issue #23347, asyncio: send_signal(), terminate(), kill() don't check if the

victor.stinner python-checkins at python.org
Fri Jan 30 01:22:10 CET 2015


https://hg.python.org/cpython/rev/c1d92f7221a5
changeset:   94389:c1d92f7221a5
branch:      3.4
parent:      94387:173d4a8e1e74
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Jan 30 01:20:44 2015 +0100
summary:
  Issue #23347, asyncio: send_signal(), terminate(), kill() don't check if the
transport was closed. The check broken a Tulip example and this limitation is
arbitrary. Check if _proc is None should be enough.

Enhance also close(): do nothing when called the second time.

files:
  Lib/asyncio/base_subprocess.py           |   7 ++---
  Lib/test/test_asyncio/test_subprocess.py |  16 ------------
  2 files changed, 3 insertions(+), 20 deletions(-)


diff --git a/Lib/asyncio/base_subprocess.py b/Lib/asyncio/base_subprocess.py
--- a/Lib/asyncio/base_subprocess.py
+++ b/Lib/asyncio/base_subprocess.py
@@ -84,6 +84,8 @@
         raise NotImplementedError
 
     def close(self):
+        if self._closed:
+            return
         self._closed = True
 
         for proto in self._pipes.values():
@@ -100,8 +102,7 @@
             except ProcessLookupError:
                 pass
 
-            # Don't clear the _proc reference yet because _post_init() may
-            # still run
+            # Don't clear the _proc reference yet: _post_init() may still run
 
     # On Python 3.3 and older, objects with a destructor part of a reference
     # cycle are never destroyed. It's not more the case on Python 3.4 thanks
@@ -125,8 +126,6 @@
             return None
 
     def _check_proc(self):
-        if self._closed:
-            raise ValueError("operation on closed transport")
         if self._proc is None:
             raise ProcessLookupError()
 
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -47,22 +47,6 @@
                         None, None, None, 0, waiter=waiter)
         return (transport, protocol)
 
-    def test_close(self):
-        waiter = asyncio.Future(loop=self.loop)
-        transport, protocol = self.create_transport(waiter)
-        transport._process_exited(0)
-        transport.close()
-
-        # The loop didn't run yet
-        self.assertFalse(protocol.connection_made.called)
-
-        # methods must raise ProcessLookupError if the transport was closed
-        self.assertRaises(ValueError, transport.send_signal, signal.SIGTERM)
-        self.assertRaises(ValueError, transport.terminate)
-        self.assertRaises(ValueError, transport.kill)
-
-        self.loop.run_until_complete(waiter)
-
     def test_proc_exited(self):
         waiter = asyncio.Future(loop=self.loop)
         transport, protocol = self.create_transport(waiter)

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list