jknupp jknupp - 2 years ago 108
Python Question

Background processing in Django without Celery

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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download