Skip to content

Commit

Permalink
Delay when not doing a dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjrw committed Jun 8, 2023
1 parent 290b05d commit de6ef4e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion notifier/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
notify,
pick_channels_to_notify,
)
from notifier.timing import now, override_current_time
from notifier.timing import delay, now, override_current_time
from notifier.types import AuthConfig, LocalConfig

logger = logging.getLogger(__name__)
Expand All @@ -34,6 +34,14 @@ def main(
override_current_time(force_current_time)
logger.info("The current time is %s", now)

if dry_run:
logger.info("Performing a dry run - no notifications will be sent")
else:
logger.info(
"Not performing a dry run - cancel within 5s if not intended"
)
delay()

# Database stores forum posts and caches subscriptions
DatabaseDriver = resolve_driver_from_config(config["database"]["driver"])
database = DatabaseDriver(
Expand Down
6 changes: 6 additions & 0 deletions notifier/timing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime, timedelta
import logging
import time

import pycron

Expand All @@ -16,6 +17,11 @@ def override_current_time(time: str):
logger.info(f"Current time forcibly overridden with {time}")


def delay():
"""Pause for a moment."""
time.sleep(5)


def channel_is_now(crontab: str):
"""Checks if the given notification channel should be activated right
now."""
Expand Down

0 comments on commit de6ef4e

Please sign in to comment.