On 6 Jul 2012, at 5:31 PM, Massimo DiPierro wrote:
> It is true that softcron makes a new instance at every request. The instance runs in its own thread and it locks the crontab file. (therefore it serializes the picking of cron tasks but not the original request).
>
> That is how it was originally designed. This was for system running - for example - cgi and not cam able of running a background task.
>
> If you would change it, how would you change?
At the very least, some what to ensure that my first example below would run even if no requests comes in during minute 0, and that only one request would run on the minute.
> What use case do you have in mind that is not covered by hardcron?
mod_wsgi.
I suppose I'll go to extcron, or something like that. I was hoping for a more self-contained solution, though.
I like the idea of the scheduler, but I'd prefer that it be self-starting. And the existing scheduler code looks way too complicated to debug.
My use case: I'm using a database to keep a history of video feeds, and also as a cache. Client requests are satisfied from the (cached) db table, and a background task periodically polls the feed sources and updates the table. The "homemade task queue" in the book would do, but I was looking for a simple way to guarantee that there was always exactly one copy running (except during an update), and I was having trouble doing that—it keeps getting overcomplicated.
Seems to me that kind of simple requirement must be a common one, and it'd be nice to have a built-in mechanism to satisfy it.
I'm also looking at coordinating it through memcached, so as to be able to work with multiple servers. But that's anther story.