summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Shepelev <temotor@gmail.com>2016-01-24 23:27:52 +0500
committerSergey Shepelev <temotor@gmail.com>2016-01-24 23:36:38 +0500
commit8ea9df6b9f6a13bb47feb35bacc60968c5ce4b43 (patch)
treea692226b8d5f74f4d584799d0ecbe8544fb3eab3
parenta79c0ee57af25ab176e34ae7ceb27a1c0262ae5d (diff)
downloadeventlet-issue-290.tar.gz
patcher: certain order of import subprocess and monkey_patch breaks .communicate()issue-290
https://github.com/eventlet/eventlet/issues/290
-rw-r--r--eventlet/green/select.py4
-rw-r--r--tests/isolated/patcher_blocking_select_methods_are_deleted.py4
-rw-r--r--tests/isolated/subprocess_patched_communicate.py13
-rw-r--r--tests/subprocess_test.py14
4 files changed, 31 insertions, 4 deletions
diff --git a/eventlet/green/select.py b/eventlet/green/select.py
index 60301d3..d1cba12 100644
--- a/eventlet/green/select.py
+++ b/eventlet/green/select.py
@@ -6,7 +6,9 @@ from eventlet.support import six
__patched__ = ['select']
-__deleted__ = ['devpoll', 'poll', 'epoll', 'kqueue', 'kevent']
+# FIXME: must also delete `poll`, but it breaks subprocess `communicate()`
+# https://github.com/eventlet/eventlet/issues/290
+__deleted__ = ['devpoll', 'epoll', 'kqueue', 'kevent']
def get_fileno(obj):
diff --git a/tests/isolated/patcher_blocking_select_methods_are_deleted.py b/tests/isolated/patcher_blocking_select_methods_are_deleted.py
index 7a27980..d701e0e 100644
--- a/tests/isolated/patcher_blocking_select_methods_are_deleted.py
+++ b/tests/isolated/patcher_blocking_select_methods_are_deleted.py
@@ -9,7 +9,9 @@ if __name__ == '__main__':
# * https://bitbucket.org/eventlet/eventlet/issues/167
# * https://github.com/eventlet/eventlet/issues/169
import select
- for name in ['devpoll', 'poll', 'epoll', 'kqueue', 'kevent']:
+ # FIXME: must also delete `poll`, but it breaks subprocess `communicate()`
+ # https://github.com/eventlet/eventlet/issues/290
+ for name in ['devpoll', 'epoll', 'kqueue', 'kevent']:
assert not hasattr(select, name), name
import sys
diff --git a/tests/isolated/subprocess_patched_communicate.py b/tests/isolated/subprocess_patched_communicate.py
new file mode 100644
index 0000000..fb8aab0
--- /dev/null
+++ b/tests/isolated/subprocess_patched_communicate.py
@@ -0,0 +1,13 @@
+# no standard tests in this file, ignore
+__test__ = False
+
+
+if __name__ == '__main__':
+ import sys
+ import eventlet
+ import subprocess
+ eventlet.monkey_patch(all=True)
+ p = subprocess.Popen([sys.executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p.communicate()
+
+ print('pass')
diff --git a/tests/subprocess_test.py b/tests/subprocess_test.py
index 2220c87..1f07518 100644
--- a/tests/subprocess_test.py
+++ b/tests/subprocess_test.py
@@ -1,8 +1,10 @@
+import sys
+import time
+
import eventlet
from eventlet.green import subprocess
import eventlet.patcher
-import sys
-import time
+import tests
original_subprocess = eventlet.patcher.original('subprocess')
@@ -73,3 +75,11 @@ def test_universal_lines():
stdout=subprocess.PIPE,
universal_newlines=True)
p.communicate(None)
+
+
+def test_patched_communicate_290():
+ # https://github.com/eventlet/eventlet/issues/290
+ # Certain order of import and monkey_patch breaks subprocess communicate()
+ # with AttributeError module `select` has no `poll` on Linux
+ # unpatched methods are removed for safety reasons in commit f63165c0e3
+ tests.run_isolated('subprocess_patched_communicate.py')