summaryrefslogtreecommitdiff
path: root/trollius/base_subprocess.py
diff options
context:
space:
mode:
Diffstat (limited to 'trollius/base_subprocess.py')
-rw-r--r--trollius/base_subprocess.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/trollius/base_subprocess.py b/trollius/base_subprocess.py
index 13cff7a..ffd6e76 100644
--- a/trollius/base_subprocess.py
+++ b/trollius/base_subprocess.py
@@ -1,8 +1,8 @@
import collections
import subprocess
-import sys
import warnings
+from . import compat
from . import futures
from . import protocols
from . import transports
@@ -36,8 +36,13 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
self._pipes[2] = None
# Create the child process: set the _proc attribute
- self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
- stderr=stderr, bufsize=bufsize, **kwargs)
+ try:
+ self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
+ stderr=stderr, bufsize=bufsize, **kwargs)
+ except:
+ self.close()
+ raise
+
self._pid = self._proc.pid
self._extra['subprocess'] = self._proc
@@ -112,7 +117,7 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
# 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
# to the PEP 442.
- if sys.version_info >= (3, 4):
+ if compat.PY34:
def __del__(self):
if not self._closed:
warnings.warn("unclosed transport %r" % self, ResourceWarning)