Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions codeflash/tracing/tracing_new_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import threading
import time
from collections import defaultdict
from importlib.util import find_spec
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, ClassVar

Expand Down Expand Up @@ -47,6 +48,18 @@ def __init__(self, code: FakeCode, prior: FakeFrame | None) -> None:
self.f_locals: dict = {}


def patch_ap_scheduler() -> None:
if find_spec("apscheduler") is None:

import apscheduler.schedulers.background as bg
import apscheduler.schedulers.blocking as bb
from apscheduler.schedulers import base

bg.BackgroundScheduler.start = lambda _, *_a, **_k: None
bb.BlockingScheduler.start = lambda _, *_a, **_k: None
base.BaseScheduler.add_job = lambda _, *_a, **_k: None


# Debug this file by simply adding print statements. This file is not meant to be debugged by the debugger.
class Tracer:
"""Use this class as a 'with' context manager to trace a function call.
Expand Down Expand Up @@ -839,6 +852,7 @@ def runctx(self, cmd: str, global_vars: dict[str, Any], local_vars: dict[str, An
}
args_dict["config"]["module_root"] = Path(args_dict["config"]["module_root"])
args_dict["config"]["tests_root"] = Path(args_dict["config"]["tests_root"])
patch_ap_scheduler()
tracer = Tracer(
config=args_dict["config"],
output=Path(args_dict["output"]),
Expand Down
Loading