From 2b6affe8c424f3798aa9978e078b3c800ff6919c Mon Sep 17 00:00:00 2001 From: Alex Al-Saffar Date: Thu, 19 Dec 2024 17:29:46 +0300 Subject: [PATCH] Fix type hint for wait parameter in Scheduler and update str2timedelta usage --- myresources/crocodile/meta.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/myresources/crocodile/meta.py b/myresources/crocodile/meta.py index c3a2e65..50aea0c 100644 --- a/myresources/crocodile/meta.py +++ b/myresources/crocodile/meta.py @@ -535,11 +535,11 @@ def print_summary(self): class Scheduler: - def __init__(self, routine: Callable[['Scheduler'], Any], wait: Union[str, int] = "2m", max_cycles: int = 10000000000, + def __init__(self, routine: Callable[['Scheduler'], Any], wait: Union[str, int, float] = "2m", max_cycles: int = 10000000000, exception_handler: Optional[Callable[[Union[Exception, KeyboardInterrupt], str, 'Scheduler'], Any]] = None, logger: Optional[Log] = None, sess_stats: Optional[Callable[['Scheduler'], dict[str, Any]]] = None, records: Optional[list[list[Any]]] = None): self.routine = routine # main routine to be repeated every `wait` time period - self.wait_sec = str2timedelta(wait).total_seconds() if isinstance(wait, str) else wait # wait period between routine cycles. + self.wait_sec = str2timedelta(shift=wait).total_seconds() if isinstance(wait, str) else wait # wait period between routine cycles. self.logger = logger if logger is not None else Log(name="SchedLogger_" + randstr(noun=True)) self.exception_handler = exception_handler if exception_handler is not None else self.default_exception_handler self.sess_start_time = datetime.now() # to be reset at .run