I've been using the excellent schedule
library to run a variety of jobs, but there is one thing I can't find.
The Python code for running a job every 10 minutes looks like this:
schedule.every(10).minutes.do(job)
Question is: how would I elegantly incorporate the time unit as a variable? I want to do something like this:
interval = 3
time_unit = 'hours'
schedule.every(interval).units(time_unit).do(job)
to run a job every 3 hours. Using variables would allow the schedule to be configurable.
Except the example above isn't working: the units
member is a readable value only.
eval
is not safe in this context.