Use method fetch_current_thread_functor from oslo.utils

oslo.utils provides this method, just use it and don't
keep the version of oslo.messaging.

Change-Id: If71dde829382a46bb95897cf89377428097b18dd
This commit is contained in:
ChangBo Guo(gcb) 2016-09-24 15:22:44 +08:00
parent f468fcd755
commit ae365cb688
2 changed files with 2 additions and 22 deletions

View File

@ -32,6 +32,7 @@ import kombu.entity
import kombu.messaging import kombu.messaging
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import eventletutils
from oslo_utils import netutils from oslo_utils import netutils
import six import six
from six.moves.urllib import parse from six.moves.urllib import parse
@ -400,7 +401,7 @@ class ConnectionLock(DummyConnectionLock):
self._monitor = threading.Lock() self._monitor = threading.Lock()
self._workers_locks = threading.Condition(self._monitor) self._workers_locks = threading.Condition(self._monitor)
self._heartbeat_lock = threading.Condition(self._monitor) self._heartbeat_lock = threading.Condition(self._monitor)
self._get_thread_id = _utils.fetch_current_thread_functor() self._get_thread_id = eventletutils.fetch_current_thread_functor()
def acquire(self): def acquire(self):
with self._monitor: with self._monitor:

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import threading
def version_is_compatible(imp_version, version): def version_is_compatible(imp_version, version):
"""Determine whether versions are compatible. """Determine whether versions are compatible.
@ -49,25 +47,6 @@ def version_is_compatible(imp_version, version):
return True return True
def fetch_current_thread_functor():
# Until https://github.com/eventlet/eventlet/issues/172 is resolved
# or addressed we have to use complicated workaround to get a object
# that will not be recycled; the usage of threading.current_thread()
# doesn't appear to currently be monkey patched and therefore isn't
# reliable to use (and breaks badly when used as all threads share
# the same current_thread() object)...
try:
import eventlet
from eventlet import patcher
green_threaded = patcher.is_monkey_patched('thread')
except ImportError:
green_threaded = False
if green_threaded:
return lambda: eventlet.getcurrent()
else:
return lambda: threading.current_thread()
class DummyLock(object): class DummyLock(object):
def acquire(self): def acquire(self):
pass pass