diff --git a/services/scheduler/app.py b/services/scheduler/app.py index 318483b..1a33800 100644 --- a/services/scheduler/app.py +++ b/services/scheduler/app.py @@ -12,21 +12,6 @@ import logging from datetime import datetime from typing import Any, Optional - -def _ensure_dict(val: Any) -> Optional[dict]: - """Coerce a JSONB value (dict or JSON string) to a Python dict.""" - if val is None: - return None - if isinstance(val, dict): - return val - if isinstance(val, str): - try: - parsed = json.loads(val) - return parsed if isinstance(parsed, dict) else None - except (json.JSONDecodeError, TypeError): - return None - return None - import asyncpg import redis.asyncio as aioredis @@ -42,6 +27,21 @@ from services.shared.redis_keys import ( logger = logging.getLogger("scheduler") + +def _ensure_dict(val: Any) -> Optional[dict]: + """Coerce a JSONB value (dict or JSON string) to a Python dict.""" + if val is None: + return None + if isinstance(val, dict): + return val + if isinstance(val, str): + try: + parsed = json.loads(val) + return parsed if isinstance(parsed, dict) else None + except (json.JSONDecodeError, TypeError): + return None + return None + # Default polling cadences by source class (seconds). # Individual sources can override via config.polling_interval_seconds. DEFAULT_CADENCES: dict[str, int] = {