Skip to content

Commit

Permalink
add logging to exception catch
Browse files Browse the repository at this point in the history
  • Loading branch information
eschutho committed Nov 12, 2021
1 parent 710f179 commit 07e11fd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions superset/tasks/cron_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
from datetime import datetime, timedelta, timezone as dt_timezone
from typing import Iterator

import logging
from croniter import croniter
from pytz import timezone as pytz_timezone, UnknownTimeZoneError

from superset import app

logger = logging.getLogger(__name__)


def cron_schedule_window(cron: str, timezone: str) -> Iterator[datetime]:
window_size = app.config["ALERT_REPORTS_CRON_WINDOW_SIZE"]
Expand All @@ -33,6 +36,8 @@ def cron_schedule_window(cron: str, timezone: str) -> Iterator[datetime]:
except UnknownTimeZoneError:
# fallback to default timezone
tz = pytz_timezone("UTC")
logger.warning(
"Timezone %s was invalid. Falling back to 'UTC'", timezone)
utc = pytz_timezone("UTC")
# convert the current time to the user's local time for comparison
time_now = time_now.astimezone(tz)
Expand Down

0 comments on commit 07e11fd

Please sign in to comment.