summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Stasiak <jakub.stasiak@smarkets.com>2016-05-18 16:51:54 +0200
committerJakub Stasiak <jakub.stasiak@smarkets.com>2016-05-20 00:21:19 +0200
commit792c4d4b1fe5e14e342ed71f9e9ee2109bf72f99 (patch)
tree5d6ee3a2be87c6cf80c7c38343cf12e0f2130cdf
parent97e8bdab683e09a865e6e66b2cc1bf1073207d4a (diff)
downloadeventlet-select-subprocess.tar.gz
green subprocess: Provide green check_outputselect-subprocess
This patch is contributed by Smarkets Limited.
-rw-r--r--eventlet/green/subprocess.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/eventlet/green/subprocess.py b/eventlet/green/subprocess.py
index 9f14596..597dfdf 100644
--- a/eventlet/green/subprocess.py
+++ b/eventlet/green/subprocess.py
@@ -115,7 +115,17 @@ class Popen(subprocess_orig.Popen):
except AttributeError:
pass
+
# Borrow subprocess.call() and check_call(), but patch them so they reference
# OUR Popen class rather than subprocess.Popen.
-call = FunctionType(six.get_function_code(subprocess_orig.call), globals())
-check_call = FunctionType(six.get_function_code(subprocess_orig.check_call), globals())
+def patched_function(function):
+ return FunctionType(six.get_function_code(function), globals())
+
+
+call = patched_function(subprocess_orig.call)
+check_call = patched_function(subprocess_orig.check_call)
+# check_output is Python 2.7+
+if hasattr(subprocess_orig, 'check_output'):
+ __patched__.append('check_output')
+ check_output = patched_function(subprocess_orig.check_output)
+del patched_function