Schedule – Python job scheduling for humans
github.com
github.com
In fact, it can be quite difficult to reason about. What, for example is "schedule. every(10)"? By itself, it does not seem to represent a useful concept other than a "partial" schedule statement.
I would prefer to use an api using keyword arguments to set the various (optional) parameters to build a schedule.
Wouldn't it be better to have descriptions of:
Every day at 10:30 do myfunc
Every Monday do otherfunc
Every hour do whatever
Rather than the current .every().day.at("10:30").do(myfunc)?
crontab(hour=18, minute=30, day_of_week='*')
[1]: http://celery.readthedocs.org/en/latest/userguide/periodic-t...[2]: https://labix.org/python-dateutil#head-470fa22b2db72000d7abe...
This is not Pythonic at all <troll>it's like some childish Ruby code</troll>
We extended [2] django-celery db backend to store enough information about the periodic tasks to retry them directly in Django admin or to filter the results (we support storing the task results in JSON instead of pickle).
Celery is probably more difficult to configure but is far more flexible and robust than this lib...
[1] http://celery.readthedocs.org/en/latest/userguide/periodic-t... [2] https://github.com/resulto-admin/django-celery-fulldbresult
Is there any system out there that has a good design for handling these issues?
Have many out of process (on disk) files that contain some or all of the phrases "start package a with Params b at time c"
And have the scheduler pass over the actual running to another process - possibly another machine entirely
Would like to get my teeth into that
I get very uncomfortable with any kind of polling, especially polling timers for checking for jobs with timespans between them. Maybe it's just me?
Even the Unix cron is implemented with a sleep() call
Job scheduling when things fail is harder
It implies the other tools are possibly designed by monkeys, to a degree, which is often totally not the case.
As a particular example, while some libs are "friendly", they are also limited.
In this case, celery is implied to be not "for humans", but it actually offers distributed job queuing and jobs that can survive a reboot, which is pretty darn important.
I'm not going to name names of other libs doing this, but there are a few that have picked API simplicity over complete feature set. This is obviously a balance - BUT I think it unfairly casts the alternatively libs in a questionable light, and often they can do a lot more.
FWIW, the Ruby-design into the method space can also be reduced if desired to make this a bit more Pythonic (though some things are personal preferences):
scheduler = schedule.scheduler()
scheduler(callback=job).every(minutes=10)
scheduler(callback=job).every(day=1).at(hour=10, minutes=30)
Having functions like "Wednesday" or "minutes" complicate programatic usage, where in the above, it would be possible to pass in a constant.One thing I also notice (not sure if Ruby inspired or not), is that it's keeping global state in the module (see run_pending) rather than having different scheduler objects. This somewhat limits reusability by having this embedded magic and not being able to isolate schedulers.
I agree about the for humans branding.
I also don't find this api very appealing, but I haven't given much consideration to what an interval api should look like.
That said, I personally don't think Celery suffers from this problem, but API that was being replaced by the first project to used this moniker - urllib2 - definitively did.
For curious: that was python library requests. And the claim was more than deserved in that case.
I don't think it's fair to say the other tools weren't designed, or merely designed the easy way.
urllib2 has some rough edges - and some things should be better, but it can also do some things requests can't do, and I've had to reach for it on a few occasions. requests has basically optimized for the easy case, where
urllib2 wished to be more flexible in certain areas, so it deserves some merit there too.
There's certainly an implication that other libraries are designed without sufficient attention to human factors, and maybe that's kinda rude, but the same goes for making any positive claim. "A library for efficient high-precision computations": are all the others inefficient? "A flexible and powerful tool for retrieving structured data from web APIs": are all the others inflexible and weak? "A standard-conformant C++ parser": are all the others broken? (None of those examples, so far as I know, are from real projects, but clearly they all could be.)
> "for humans"
The earliest example of this that I could find is from a 2007 article by Jeff Atwood entitled "Sorting for Humans : Natural Sort Order". Coincidentally, Atwood double-dipped on it a few months later with an article called "Monkeypatching for Humans" (but I think he meant "monkey" in a different way).I think in recent years, Kenneth Reitz has really taken "for humans" and run with it: "Python for Humans", "Deployment for Humans", "requests: HTTP for Humans". He's even gone so far as to (facetiously?) trademark it ("args: Argument Parsing for Humans™"). Now everything with syntactic sugar is "for humans".
If you think your API represents a breakthrough in simplicity then trust me: it will do the talking for you.