Skip to content

Commit

Permalink
refactor(meta.py): modify wait_sec initialization to handle both stri…
Browse files Browse the repository at this point in the history
…ng and integer input types for better flexibility and compatibility
  • Loading branch information
Alex Al-Saffar committed Jun 7, 2024
1 parent 473b044 commit 1c03bcd
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 @@ -499,11 +499,11 @@ def print_summary(self):


class Scheduler:
def __init__(self, routine: Callable[['Scheduler'], Any], wait: str = "2m", max_cycles: int = 10000000000,
def __init__(self, routine: Callable[['Scheduler'], Any], wait: Union[str, int] = "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() # wait period between routine cycles.
self.wait_sec = str2timedelta(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 1c03bcd

Please sign in to comment.