Coverage for watcher/cmd/__init__.py: 100%

2 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-06-17 12:22 +0000

1# 

2# Licensed under the Apache License, Version 2.0 (the "License"); you may 

3# not use this file except in compliance with the License. You may obtain 

4# a copy of the License at 

5# 

6# http://www.apache.org/licenses/LICENSE-2.0 

7# 

8# Unless required by applicable law or agreed to in writing, software 

9# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

10# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

11# License for the specific language governing permissions and limitations 

12# under the License. 

13 

14# NOTE(licanwei): Do eventlet monkey patching here, instead of in 

15# common/service.py. This allows the API service to run without monkey 

16# patching under Apache (which uses its own concurrency model). Mixing 

17# concurrency models can cause undefined behavior and potentially API timeouts. 

18# NOTE(sean-k-mooney) while ^ is true, since that was written asyncio was added 

19# to the code base in addition to apscheduler which provides native threads. 

20# As such we have a lot of technical debt to fix with regards to watchers 

21# concurrency model as we are mixing up to 3 models the same process. 

22# apscheduler does not technically support eventlet but it has mostly worked 

23# until now, apscheduler is used to provide a job schedulers which mixes 

24# monkey patched and non monkey patched code in the same process. 

25# That is problematic and can lead to errors on python 3.12+. 

26# The maas support added asyncio to the codebase which is unsafe to mix 

27# with eventlets by default. 

28from watcher import eventlet 

29eventlet.patch()