fix: scheduler timezone-aware datetime subtraction in is_source_due
ci/woodpecker/push/woodpecker Pipeline was successful
Build and Push / lint-and-test (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.adapters.broker_adapter name:broker-adapter]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.aggregation.worker name:aggregation]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.extractor.worker name:extractor]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.ingestion.worker name:ingestion]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.lake_publisher.worker name:lake-publisher]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.parser.worker name:parser]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.recommendation.worker name:recommendation]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.scheduler.app name:scheduler]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.api.app:app --host 0.0.0.0 --port 8000 name:query-api]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.risk.app:app --host 0.0.0.0 --port 8000 name:risk]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.symbol_registry.app:app --host 0.0.0.0 --port 8000 name:symbol-registry]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.trading.app:app --host 0.0.0.0 --port 8000 name:trading-engine]) (push) Has been cancelled
Build and Push / build-dashboard (push) Has been cancelled
Build and Push / build-superset (push) Has been cancelled
Build and Push / integration-test (push) Has been cancelled

This commit is contained in:
Celes Renata
2026-04-20 00:47:26 +00:00
parent f3aac0ac3d
commit d64ce82649
+16 -3
View File
@@ -125,8 +125,16 @@ def is_source_due(
if last_status == "failed":
if retry_count >= MAX_RETRY_COUNT:
return False
if next_retry_at and now < next_retry_at.replace(tzinfo=None):
return False
if next_retry_at:
# Normalize tz-awareness to match 'now'
if now.tzinfo is not None and next_retry_at.tzinfo is None:
nra = next_retry_at.replace(tzinfo=timezone.utc)
elif now.tzinfo is None and next_retry_at.tzinfo is not None:
nra = next_retry_at.replace(tzinfo=None)
else:
nra = next_retry_at
if now < nra:
return False
# Backoff elapsed or no next_retry_at set — allow retry
return True
@@ -139,7 +147,12 @@ def is_source_due(
return True
cadence = get_cadence_for_source(source_type, source_config)
elapsed = (now - last_completed_at.replace(tzinfo=None)).total_seconds()
# Ensure both datetimes have matching tz-awareness for subtraction
if now.tzinfo is not None and last_completed_at.tzinfo is None:
last_completed_at = last_completed_at.replace(tzinfo=timezone.utc)
elif now.tzinfo is None and last_completed_at.tzinfo is not None:
last_completed_at = last_completed_at.replace(tzinfo=None)
elapsed = (now - last_completed_at).total_seconds()
return elapsed >= cadence