Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" A collection of functions for quickly registering periodic tasks using the decorator syntax. Note that, while these functions are used as decorators, they actually return the original function, so you can decorate multiple times without worry. """
""" Creates a decorator that registers periodic tasks. """
return _create_decorator(lambda last_run: last_run < datetime.now().replace(second=0, microsecond=0) - timedelta( minutes=datetime.now().minute))
return _create_decorator(lambda last_run: last_run.date() < date.today() - timedelta(date.today().weekday()))
period = timedelta(days, seconds, microseconds, milliseconds, minutes, hours, weeks) return _create_decorator(lambda last_run: last_run <= datetime.now() - period)
os.mkdir(self.timestamp_folder)
self.last_run = pickle.load(timestamp_file)
if self.schedule(self.last_run): self.fn() self.last_run = datetime.now() with open(os.path.join(self.timestamp_folder, self.task_id), 'wb') as timestamp_file: pickle.dump(self.last_run, timestamp_file)
for task in self.tasks: task.run()
_registry.run_all_tasks()
|