Skip to content

Commit

Permalink
fix asyncz settings crash and warn for empty tasks (#408)
Browse files Browse the repository at this point in the history
Changes:

- fix crash when no tasks are provided
- fix hard to ignore UserWarning for a perfectly fine
  configuration without tasks
  • Loading branch information
devkral authored Oct 1, 2024
1 parent 4f76f83 commit 3478e68
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions esmerald/contrib/schedulers/asyncz/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import warnings
from datetime import datetime, timezone as dtimezone
from typing import Any, Callable, Dict, Type, Union

Expand Down Expand Up @@ -41,7 +40,7 @@ def __init__(
"""
super().__init__(**kwargs)
self.scheduler_class = scheduler_class
self.tasks = tasks
self.tasks = tasks or {}
self.timezone = timezone
self.configurations = configurations
self.options = kwargs
Expand All @@ -50,13 +49,6 @@ def __init__(
if not isinstance(task, str) or not isinstance(module, str):
raise ImproperlyConfigured("The dict of tasks must be Dict[str, str].")

if not self.tasks:
warnings.warn(
"Esmerald is starting the scheduler, yet there are no tasks declared.",
UserWarning,
stacklevel=2,
)

# Load the scheduler object
self.handler = self.get_scheduler(
scheduler=self.scheduler_class,
Expand Down

0 comments on commit 3478e68

Please sign in to comment.