|
13 | 13 | import threading |
14 | 14 | import time |
15 | 15 | from collections import defaultdict |
| 16 | +from importlib.util import find_spec |
16 | 17 | from pathlib import Path |
17 | 18 | from typing import TYPE_CHECKING, Any, Callable, ClassVar |
18 | 19 |
|
@@ -47,6 +48,18 @@ def __init__(self, code: FakeCode, prior: FakeFrame | None) -> None: |
47 | 48 | self.f_locals: dict = {} |
48 | 49 |
|
49 | 50 |
|
| 51 | +def patch_ap_scheduler() -> None: |
| 52 | + if find_spec("apscheduler") is None: |
| 53 | + |
| 54 | + import apscheduler.schedulers.background as bg |
| 55 | + import apscheduler.schedulers.blocking as bb |
| 56 | + from apscheduler.schedulers import base |
| 57 | + |
| 58 | + bg.BackgroundScheduler.start = lambda _, *_a, **_k: None |
| 59 | + bb.BlockingScheduler.start = lambda _, *_a, **_k: None |
| 60 | + base.BaseScheduler.add_job = lambda _, *_a, **_k: None |
| 61 | + |
| 62 | + |
50 | 63 | # Debug this file by simply adding print statements. This file is not meant to be debugged by the debugger. |
51 | 64 | class Tracer: |
52 | 65 | """Use this class as a 'with' context manager to trace a function call. |
@@ -839,6 +852,7 @@ def runctx(self, cmd: str, global_vars: dict[str, Any], local_vars: dict[str, An |
839 | 852 | } |
840 | 853 | args_dict["config"]["module_root"] = Path(args_dict["config"]["module_root"]) |
841 | 854 | args_dict["config"]["tests_root"] = Path(args_dict["config"]["tests_root"]) |
| 855 | + patch_ap_scheduler() |
842 | 856 | tracer = Tracer( |
843 | 857 | config=args_dict["config"], |
844 | 858 | output=Path(args_dict["output"]), |
|
0 commit comments