diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2016-12-05 16:55:51 -0800 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2016-12-05 16:55:54 -0800 |
commit | e2605f44eb5f6e04a04fa5c31f7ac24f1c9aaa39 (patch) | |
tree | 2925eef8a7dbc57a3dfa118df22a87a6e54af94c | |
parent | 33aa107e9b9263158b3add78e0f8f0af73b2c08b (diff) |
Tweak subprocess importing so it still ImportErrors, just lazily.
This feels better than raising our own custom error of whatever class when popen is None.
Only obvious downside is it's 'bad style' but I defer to Zen of Python number 9
Re #334
-rw-r--r-- | paramiko/proxy.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/paramiko/proxy.py b/paramiko/proxy.py index ea481bca..059ba83e 100644 --- a/paramiko/proxy.py +++ b/paramiko/proxy.py @@ -21,11 +21,6 @@ from datetime import datetime import os from shlex import split as shlsplit import signal -try: - from subprocess import Popen, PIPE -except ImportError: - # Subprocess module doesn't work on Google App Engine. - Popen = PIPE = None from select import select import socket import time @@ -53,6 +48,9 @@ class ProxyCommand(ClosingContextManager): :param str command_line: the command that should be executed and used as the proxy. """ + # NOTE: subprocess import done lazily so platforms without it (e.g. + # GAE) can still import us during overall Paramiko load. + from subprocess import Popen, PIPE self.cmd = shlsplit(command_line) self.process = Popen(self.cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, bufsize=0) |