[eventlet-deprecation] Nova notifier retrieves local thread
A new method to retrieve the local thread is implemented, depending if the ``thread`` module is monkey patched or not. This is used in the Nova notifier during the eventlet deprecation migration. Related-Bug: #2087953 Change-Id: Icc7095d8485acee06cf602ccbf899be22dfc7a53
This commit is contained in:
@@ -14,8 +14,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import threading
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
|
from eventlet.green import threading as threading_eventlet
|
||||||
|
from oslo_utils import eventletutils
|
||||||
|
|
||||||
|
|
||||||
IS_MONKEY_PATCHED = False
|
IS_MONKEY_PATCHED = False
|
||||||
@@ -38,3 +41,9 @@ def monkey_patch():
|
|||||||
p_c_e = importutils.import_module('pyroute2.config.asyncio')
|
p_c_e = importutils.import_module('pyroute2.config.asyncio')
|
||||||
p_c_e.asyncio_config()
|
p_c_e.asyncio_config()
|
||||||
IS_MONKEY_PATCHED = True
|
IS_MONKEY_PATCHED = True
|
||||||
|
|
||||||
|
|
||||||
|
def get_threading_local():
|
||||||
|
if eventletutils.is_monkey_patched('thread'):
|
||||||
|
return threading_eventlet.local()
|
||||||
|
return threading.local()
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
|
|
||||||
from eventlet.green import threading
|
|
||||||
from keystoneauth1 import exceptions as ks_exceptions
|
from keystoneauth1 import exceptions as ks_exceptions
|
||||||
from keystoneauth1 import loading as ks_loading
|
from keystoneauth1 import loading as ks_loading
|
||||||
from neutron_lib.callbacks import events
|
from neutron_lib.callbacks import events
|
||||||
@@ -35,6 +34,7 @@ from oslo_utils import uuidutils
|
|||||||
from sqlalchemy.orm import attributes as sql_attr
|
from sqlalchemy.orm import attributes as sql_attr
|
||||||
import tenacity
|
import tenacity
|
||||||
|
|
||||||
|
from neutron.common import eventlet_utils
|
||||||
from neutron.notifiers import batch_notifier
|
from neutron.notifiers import batch_notifier
|
||||||
|
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ NOTIFIER_ENABLE_DEFAULT = True
|
|||||||
# callbacks from the agents (DHCP, L2), trying to update the provisioning
|
# callbacks from the agents (DHCP, L2), trying to update the provisioning
|
||||||
# status of a port. In order to handle each context notifier enable flag, a
|
# status of a port. In order to handle each context notifier enable flag, a
|
||||||
# thread local variable is used.
|
# thread local variable is used.
|
||||||
_notifier_store = threading.local()
|
_notifier_store = eventlet_utils.get_threading_local()
|
||||||
|
|
||||||
|
|
||||||
@registry.has_registry_receivers
|
@registry.has_registry_receivers
|
||||||
|
Reference in New Issue
Block a user