summaryrefslogtreecommitdiff
path: root/oslo_rootwrap/client.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2015-10-13 21:26:39 +0200
committerVictor Stinner <vstinner@redhat.com>2015-10-13 21:51:47 +0200
commit31cfdbd4076bb6556cf9612171ba43fa44475d71 (patch)
tree9e5f7800bd815ecdce9b7f3930ecf74de7b6cea1 /oslo_rootwrap/client.py
parent6f424f73cd340d1d6edd018de373430ca03712a6 (diff)
downloadoslo-rootwrap-31cfdbd4076bb6556cf9612171ba43fa44475d71.tar.gz
Fix Python 3 support for eventlet monkey-patching2.5.0
Use eventlet.green.subprocess if eventlet is used and enable eventlet tests on Python 3. This change adds oslo_rootwrap.subprocess which is eventlet.green.subprocess if eventlet monkey-patching is enabled or if the TEST_EVENTLET environment variable is set, or subprocess of the Python standard library otherwise. When eventlet is used (with monkey-patching or not), it's more reliable to use eventlet.green.subprocess instead of using directly subprocess from the Python standard library. On Python 2, it "works" to use directly subprocess: subprocess.Popen calls os.pipe() and os.fdopen(fd) which are both monkey-patched. On Python 3, it doesn't work because subprocess uses os.pipe() and io.open(fd), and the io module is *not* monkey-patched at all. Change-Id: Ib859bebe52612b35f0f1f53aedf76222683795e7
Diffstat (limited to 'oslo_rootwrap/client.py')
-rw-r--r--oslo_rootwrap/client.py15
1 files changed, 3 insertions, 12 deletions
diff --git a/oslo_rootwrap/client.py b/oslo_rootwrap/client.py
index 6f7fd37..dec161e 100644
--- a/oslo_rootwrap/client.py
+++ b/oslo_rootwrap/client.py
@@ -16,24 +16,15 @@
import logging
from multiprocessing import managers
from multiprocessing import util as mp_util
-import os
-import subprocess
import threading
import weakref
-try:
- import eventlet.patcher
-except ImportError:
- patched_socket = False
-else:
- # In tests patching happens later, so we'll rely on environment variable
- patched_socket = (eventlet.patcher.is_monkey_patched('socket') or
- os.environ.get('TEST_EVENTLET', False))
-
+import oslo_rootwrap
from oslo_rootwrap import daemon
from oslo_rootwrap import jsonrpc
+from oslo_rootwrap import subprocess
-if patched_socket:
+if oslo_rootwrap._patched_socket:
# We have to use slow version of recvall with eventlet because of a bug in
# GreenSocket.recv_into:
# https://bitbucket.org/eventlet/eventlet/pull-request/41