diff options
author | John Eckersberg <jeckersb@redhat.com> | 2021-09-22 14:45:33 -0400 |
---|---|---|
committer | John Eckersberg <jeckersb@redhat.com> | 2021-09-22 14:45:39 -0400 |
commit | ca939fc0e4683efce87b567a9a074063a9c75b4f (patch) | |
tree | f9af53d3f83bc33ed504e0406c96232b9db5a506 /oslo_messaging/_utils.py | |
parent | d4f7ea21fc10ec00aaac5ca16bcb5903c3e81bac (diff) | |
download | oslo-messaging-ca939fc0e4683efce87b567a9a074063a9c75b4f.tar.gz |
rabbit: move stdlib_threading bits into _utils12.10.0
The amqp1 driver also needs this same logic, so split it out and share
it.
Change-Id: I2e9dbfa27887e26807f199c9d359bacd7c15c67a
Diffstat (limited to 'oslo_messaging/_utils.py')
-rw-r--r-- | oslo_messaging/_utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/oslo_messaging/_utils.py b/oslo_messaging/_utils.py index 969bdbb..0ce1a16 100644 --- a/oslo_messaging/_utils.py +++ b/oslo_messaging/_utils.py @@ -14,11 +14,25 @@ # under the License. import logging +import threading from oslo_utils import eventletutils +from oslo_utils import importutils LOG = logging.getLogger(__name__) +eventlet = importutils.try_import('eventlet') +if eventlet and eventletutils.is_monkey_patched("thread"): + # Here we initialize module with the native python threading module + # if it was already monkey patched by eventlet/greenlet. + stdlib_threading = eventlet.patcher.original('threading') +else: + # Manage the case where we run this driver in a non patched environment + # and where user even so configure the driver to run heartbeat through + # a python thread, if we don't do that when the heartbeat will start + # we will facing an issue by trying to override the threading module. + stdlib_threading = threading + def version_is_compatible(imp_version, version): """Determine whether versions are compatible. |