bedb19bb22
This patch is adding a check to prevent calling ``eventlet.monkey_patch()`` more than once per execution. This patch is also preventing any import before this method has been called. Any import is moved after that. Closes-Bug: #2091538 Topic: eventlet-deprecation Change-Id: I675aaf124d6630b6827febb1e5a5f492ed874107
32 lines
997 B
Python
32 lines
997 B
Python
# Copyright (c) 2015 Cloudbase Solutions.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import eventlet
|
|
|
|
|
|
IS_MONKEY_PATCHED = False
|
|
|
|
|
|
def monkey_patch():
|
|
global IS_MONKEY_PATCHED
|
|
if not IS_MONKEY_PATCHED:
|
|
eventlet.monkey_patch()
|
|
|
|
# pylint: disable=import-outside-toplevel
|
|
from oslo_utils import importutils
|
|
p_c_e = importutils.import_module('pyroute2.config.asyncio')
|
|
p_c_e.asyncio_config()
|
|
IS_MONKEY_PATCHED = True
|