18

I have a very small part of a Django site that keeps the state of a moderated chat session between two users. Basically, the first user speaks for 3 minutes (and no one else can), then the second user speaks, then a 30 second pause, and the process is repeated one more time. I'm currently using the database and a "RoomState" model to manage the current state of the room (who can speak, etc). State transitions are affected by the client sending a "ping" AJAX POST message every 10 seconds to one of my views, which checks if it's time to change state.

This works, but definitely feels hacky. I was wondering if there was something more lightweight than django-celery + rabbitmq to manage short lived background tasks on a timer. I realize that the nature of the web/Django is stateless, but I just wanted to see if anyone had a simple suggestion to manage the state transitions in a more reliable way.

3
  • 2
    If rabbitmq is too heavyweight, consider using the Redis backend instead.
    – Brian Neal
    Jan 5, 2012 at 0:13
  • Please consider updating the selected answer.
    – coleifer
    Feb 17, 2017 at 2:07
  • I totally agree with OP everytime we need to upgrade either Django or Celery one of the two breaks. We're on scanning the web for headache number 10 now. Celery has 496 outstanding issues on git hub and a whopping 37 pull requests that are never going to be pulled in. All we ever was reliable scheduled tasks which celery is not. The devs waste their time integrating another backend no one gives a sh*** about. Dec 12, 2017 at 19:21

3 Answers 3

20

Author of django-utils here, I'd suggest trying out my newer project Huey -- has richer feature set, better docs, more stable and works with any python framework (including django). Docs.

0
7

I know only one alternative to Celery that is more lightweight: Queue in django-utils.

Another way is to use the subprocess module directly but you'll probably have to solve some problems that are already solved in Celery and django-utils.

2
  • 5
    You might want to use github.com/coleifer/huey instead i'm no longer maintaining django-utils
    – coleifer
    Jul 13, 2012 at 18:38
  • 1
    You probably want to look at Django Q which is django specific and the stated goals of the author are exactly what you are asking for. FYI: I have no affiliation and do not know the author.
    – eskhool
    Nov 16, 2016 at 12:09
5

I'd recommend django-background-tasks. I've used it in several projects and it does really well as a simple task runner. It was also recommended in Two-Scoops of Django.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.