refactor: minor TigerStyle cleanups

- export_serving.py: move `import re` to module level — was imported
  inside a loop body on every iteration
- sitemap.py: add comment documenting that the in-memory TTL cache is
  process-local (valid for single-worker deployment, Dockerfile --workers 1)
- playtomic_availability.py: use `or "10"` fallback for
  CIRCUIT_BREAKER_THRESHOLD env var to handle empty-string case

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Deeman
2026-02-24 20:50:43 +01:00
parent 83d148477d
commit 44c0dd0b8d
3 changed files with 5 additions and 2 deletions

View File

@@ -42,7 +42,7 @@ MAX_VENUES_PER_RUN = 20_000
MAX_RETRIES_PER_VENUE = 2
MAX_WORKERS = int(os.environ.get("EXTRACT_WORKERS", "1"))
RECHECK_WINDOW_MINUTES = int(os.environ.get("RECHECK_WINDOW_MINUTES", "90"))
CIRCUIT_BREAKER_THRESHOLD = int(os.environ.get("CIRCUIT_BREAKER_THRESHOLD", "10"))
CIRCUIT_BREAKER_THRESHOLD = int(os.environ.get("CIRCUIT_BREAKER_THRESHOLD") or "10")
# Parallel mode submits futures in batches so the circuit breaker can stop
# new submissions after it opens. Already-inflight futures in the current

View File

@@ -26,6 +26,7 @@ Usage:
import logging
import os
import re
import duckdb
@@ -60,7 +61,6 @@ def export_serving() -> None:
for view_name, view_sql in view_rows:
# Pattern: ... FROM "local".sqlmesh__serving.serving__name__hash;
# Strip the "local". prefix to get schema.table
import re
match = re.search(r'FROM\s+"local"\.(sqlmesh__serving\.\S+)', view_sql)
assert match, f"Cannot parse view definition for {view_name}: {view_sql[:200]}"
physical_tables.append((view_name, match.group(1)))

View File

@@ -6,6 +6,9 @@ from quart import Response
from .core import fetch_all
# Process-local cache — valid for the current single-Hypercorn-worker deployment
# (Dockerfile: `--workers 1`). If worker count increases, replace with a
# DB-backed cache (e.g. a single-row SQLite table with an expires_at column).
_cache_xml: str = ""
_cache_timestamp: float = 0.0
CACHE_TTL_SECONDS: int = 3600 # 1 hour