Use time.monotonic() instead of time.time() for fixture budget timing

Addresses review feedback: monotonic clock is immune to NTP/clock
adjustments that could skew the budget enforcement.

Co-authored-by: larohra <41490930+larohra@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-26 00:38:18 +00:00
Unverified
parent 5dd4543d9b
commit 3c46364829
@@ -544,11 +544,11 @@ def function_app_for_test(request: pytest.FixtureRequest) -> Iterator[dict[str,
func_process: subprocess.Popen[Any] | None = None
base_url = ""
port = 0
overall_start = time.time()
overall_start = time.monotonic()
attempts_made = 0
for _ in range(max_attempts):
remaining = overall_budget - (time.time() - overall_start)
remaining = overall_budget - (time.monotonic() - overall_start)
if remaining < 10:
# Not enough time for another attempt; bail out.
break
@@ -571,7 +571,7 @@ def function_app_for_test(request: pytest.FixtureRequest) -> Iterator[dict[str,
func_process = None
if func_process is None:
elapsed = int(time.time() - overall_start)
elapsed = int(time.monotonic() - overall_start)
error_message = f"Function app failed to start after {attempts_made} attempt(s) ({elapsed}s elapsed)."
if last_error is not None:
error_message += f" Last error: {last_error}"