Take the 2-minute tour ×

I'm totally confused and have no idea how to do this, so please forgive me if my description/information is bad.

So I want say to do a notification via django-notification or simply send an e-mail to one of my user when a post of his had ended like on ebay. In my database I have a model which stores the datetime of when the post is going to end, but I'm not sure how to effectively check or store a signal or something which would alert the system to alert the user when the current time is > than the end datetime.


Since I want to send an email/notification the second a post ends, I don't think I can use a scheduler to check if any post had ended, I believe this would be too inefficient, because I would have to check like every second, but like I said above, I'm not sure about anything...

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

You could use django-celery -- connect a post_save handler that checks if created is True, and if so schedules a Task that'll notify the user at the correct time (using the eta keyword arg).

share|improve this answer
yea think something like this would be good, but i'm worried about how much memory django-celery doing this would use... What's the best low memory way of doing this? –  Derek Aug 14 '11 at 7:52
add comment

It sounds to me like you've at least thought through some solutions. One thing to keep in mind though is that Django, being a web framework, is a stateless "machine". In a nutshell that means it isn't "running" at the split second that a post expires (or rather you can't assume that a request is being sent from a browser at the split second a post expires). This means that using Django to signal/send the notification is not appropriate.

However, since you know exactly when the email should be sent, it should be possible to queue the notification in Django as soon as the post is created. Some outside "program" will then have to process the queue to actually send the notification...there are all kinds of creative ways to do this, but you can certainly use python to do it.

If you want to consider using a Message Queue, take a look at RabbitMQ http://nathanborror.com/posts/2009/may/20/working-django-and-rabbitmq/

share|improve this answer
add comment

As other have said, the best solution is django-celery (https://github.com/ask/django-celery) but it's a little heavyweight if you are low on resources.

In a similar need, I have a middleware that checks the conditions and executes the needed operations (which, in my case, are just changing a boolean in some records of the database). This works for me because until someone actually access the data there is no need to change it, and because the "task" is just one UPDATE query, so it's not an unbearable load.

Otherwise you can set up a cron job every short time (1 minute? 5 minutes?) and check conditions and do consequences.

share|improve this answer
add comment

Your Answer


