File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 4
4
import hashlib
5
5
import json
6
6
import os
7
+ import re
7
8
import time
8
9
from collections import namedtuple
9
10
from datetime import datetime , timezone
@@ -83,11 +84,17 @@ async def run_scheduler(self):
83
84
while True :
84
85
interval = 60
85
86
for s in await self .get_service ('data_svc' ).locate ('schedules' ):
86
- now = datetime .now (timezone .utc )
87
87
if not croniter .croniter .is_valid (s .schedule ):
88
- self .log .warning (f"The schedule { s .id } with the format `{ s .schedule } ` is incompatible with cron!" )
89
- continue
88
+ match = re .match (r'^(\d{2}):(\d{2}):\d{2}\.\d{6}$' , s .schedule )
89
+ if match :
90
+ hour , minute = match .groups ()
91
+ s .schedule = f"{ minute } { hour } * * *"
92
+ self .log .info (f"Converted time schedule { s .id } to cron format: { s .schedule } " )
93
+ else :
94
+ self .log .warning (f"The schedule { s .id } with the format `{ s .schedule } ` is incompatible with cron!" )
95
+ continue
90
96
97
+ now = datetime .now ()
91
98
cron = croniter .croniter (s .schedule , now )
92
99
diff = now - cron .get_prev (datetime )
93
100
if interval > diff .total_seconds () > 0 :
You can’t perform that action at this time.
0 commit comments