Merge "Use eventletutils to check is_monkey_patched"

This commit is contained in:
Jenkins 2016-05-10 01:08:30 +00:00 committed by Gerrit Code Review
commit 0d425142b5
2 changed files with 2 additions and 15 deletions
oslo_messaging/_drivers/pika_driver

@ -14,7 +14,6 @@
import select
import socket
import sys
from oslo_utils import timeutils
from pika import exceptions as pika_exceptions
@ -32,16 +31,3 @@ PIKA_CONNECTIVITY_ERRORS = (
EXCEPTIONS_MODULE = 'exceptions' if six.PY2 else 'builtins'
INFINITE_STOP_WATCH = timeutils.StopWatch(duration=None).start()
def is_eventlet_monkey_patched(module):
"""Determines safely is eventlet patching for module enabled or not
:param module: String, module name
:return Bool, True if module is patched, False otherwise
"""
if 'eventlet.patcher' not in sys.modules:
return False
import eventlet.patcher
return eventlet.patcher.is_monkey_patched(module)

@ -18,6 +18,7 @@ import threading
import time
from oslo_log import log as logging
from oslo_utils import eventletutils
import pika
from pika import credentials as pika_credentials
@ -248,7 +249,7 @@ class PikaEngine(object):
# Note(dukhlov): we need to force select poller usage in case when
# 'thread' module is monkey patched becase current eventlet
# implementation does not support patching of poll/epoll/kqueue
if pika_drv_cmns.is_eventlet_monkey_patched("thread"):
if eventletutils.is_monkey_patched("thread"):
from pika.adapters import select_connection
select_connection.SELECT_TYPE = "select"