hotkit / django-async

A simple asynchronous execution Django application with proper database transaction management
http://www.kirit.com/Django%20Async
Boost Software License 1.0
35 stars 20 forks source link

Use a filelock to prevent running flush_queue concurrently #4

Closed numegil closed 10 years ago

numegil commented 11 years ago

We're using django-async for a medium-sized Django application. We have a cron job running flush_queue once per minute. If it ever takes more than a minute to run though, the runs start overlapping, and jobs get executed multiple times.

KayEss commented 11 years ago

That's brilliant. I've been meaning to look into how to do this.

I think I need to add the lockfile dependency into the setup files and I'm also tempted to refactor the locking as a decorator just to avoid making the core function any more complex than it is already :)

The biggest thing though is the lock file name. I think the path needs to be outside of the code, for cases where the code is deployed into a read only filesystem, and the other is that the lock name needs to depend on the project name in some way for the case where there are more than one Django projects deployed on the same machine.

I'm not sure how bit either of those is though, so I'll pull this at least as far as develop as soon as I get a chance so that it can be tested a bit more.

KayEss commented 10 years ago

@numegil You'll find this in version 0.5.1 and later if you want to switch back to the official release.