-
Notifications
You must be signed in to change notification settings - Fork 971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to pass .every(10).minutes as a string to schedule #169
Comments
If I am able to understand the problem correctly, this doesn't look like a schedule package problem per-se. However, this are the following ways to solve it:
Code sample:
Code sample:
|
I'd like something similar - the user to be able to express a scheduled task as a human readable string "every day at 10:30" |
@nzjrs I wanted a config file and so wrote something that can parse JSON. "frequency": {
"every": "day",
"at": "10:30"
}, or "frequency": {
"every": [ 10, "seconds"]
}, and then when scheduling def from_json(job_dict):
frequency = job_dict.get('frequency')
if frequency is None:
raise MalformedJobException(job_dict['name'], "Frequency is missing from job definition!")
if type(frequency['every']) is list:
job = scheduler.every(frequency['every'][0])
job = getattr(job, frequency['every'][1])
else:
job = scheduler.every()
job = getattr(job, frequency['every'])
if frequency.get('at', None):
job = job.at(frequency.get('at')) where |
I was looking for some native support and then I found this issue. I needed more of a line in the properties file than a json per se, so I made this based on @jchacks 's work:
It would be a good addition to have native support for this, as we need to change schedule settings in production sometimes |
This is really neat feature, what does core team thinks about it? |
Hello Dan
i´m using the schedule.
However i would like to know how to pass
".every(10).minutes"
or
".every().day.at('10:30')"
etc
as a string to schedule
because i have a loop over a dict where i have around 15 tasks and each has its field with the "every().." defined.
Regards
António
The text was updated successfully, but these errors were encountered: