From bcd3bf7911b3f201a0f9bd7d60889c146ad5178f Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 27 Sep 2019 14:47:27 +0200 Subject: [PATCH] Support for seconds in cron expressions --- platypush/cron/scheduler.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platypush/cron/scheduler.py b/platypush/cron/scheduler.py index 5b67b7da7a..b38c2a537d 100644 --- a/platypush/cron/scheduler.py +++ b/platypush/cron/scheduler.py @@ -28,9 +28,12 @@ class Cronjob(Thread): def should_run(self): - units = ('minute', 'hour', 'day', 'month', 'year') - now = datetime.datetime.fromtimestamp(time.time()) cron_units = re.split('\s+', self.cron_expression) + units = ('second', 'minute', 'hour', 'day', 'month', 'year') \ + if len(cron_units) > 5 else \ + ('minute', 'hour', 'day', 'month', 'year') + + now = datetime.datetime.fromtimestamp(time.time()) for i in range(0, len(units)): unit = units[i]