Coverage for watcher/eventlet.py: 94%
13 statements
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-17 12:22 +0000
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-17 12:22 +0000
1# All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14import os
17MONKEY_PATCHED = False
20def is_patched():
21 return MONKEY_PATCHED
24def _monkey_patch():
25 if is_patched():
26 return
27 # Anything imported here will not be monkey patched. It is
28 # important to take care not to import anything here which requires monkey
29 # patching. eventlet processes environment variables at import-time.
30 # as such any eventlet configuration should happen here if needed.
31 import eventlet
32 eventlet.monkey_patch()
35def patch():
36 # This is only for debugging, this should not be used in production.
37 if (os.environ.get('OS_WATCHER_DISABLE_EVENTLET_PATCHING', '').lower() 37 ↛ exitline 37 didn't return from function 'patch' because the condition on line 37 was always true
38 not in ('1', 'true', 'yes', 'y')):
39 _monkey_patch()
40 global MONKEY_PATCHED
41 MONKEY_PATCHED = True