Use eventletutils to check is_monkey_patched
Move monkey_patched check to oslo utils by the change Depends-On: Ie24ecb54946bfba465d293185ebfda25691a8701 Reduce the function implementation from pika driver. Change-Id: Ic6cf38bc842f4b829e92a20d76c1f1b64a99968c
This commit is contained in:
parent
90e7b26016
commit
53aa3a57d9
@ -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"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user