Merge "Use eventletutils to check is_monkey_patched"
This commit is contained in:
commit
0d425142b5
oslo_messaging/_drivers/pika_driver
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import select
|
import select
|
||||||
import socket
|
import socket
|
||||||
import sys
|
|
||||||
|
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from pika import exceptions as pika_exceptions
|
from pika import exceptions as pika_exceptions
|
||||||
@ -32,16 +31,3 @@ PIKA_CONNECTIVITY_ERRORS = (
|
|||||||
EXCEPTIONS_MODULE = 'exceptions' if six.PY2 else 'builtins'
|
EXCEPTIONS_MODULE = 'exceptions' if six.PY2 else 'builtins'
|
||||||
|
|
||||||
INFINITE_STOP_WATCH = timeutils.StopWatch(duration=None).start()
|
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
|
import time
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_utils import eventletutils
|
||||||
import pika
|
import pika
|
||||||
from pika import credentials as pika_credentials
|
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
|
# Note(dukhlov): we need to force select poller usage in case when
|
||||||
# 'thread' module is monkey patched becase current eventlet
|
# 'thread' module is monkey patched becase current eventlet
|
||||||
# implementation does not support patching of poll/epoll/kqueue
|
# 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
|
from pika.adapters import select_connection
|
||||||
select_connection.SELECT_TYPE = "select"
|
select_connection.SELECT_TYPE = "select"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user