Skip to content

Commit

Permalink
Fix type hint for wait parameter in Scheduler and update str2timedelt…
Browse files Browse the repository at this point in the history
…a usage
  • Loading branch information
Alex Al-Saffar committed Dec 19, 2024
1 parent b2571b2 commit 2b6affe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions myresources/crocodile/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2b6affe

Please sign in to comment.