开发者

Firing notifications at specific times in Django

I created an iPhone application that I want to receive notifications at a custom time. The backend Django application has a queue of events with dates when the event reminder should be pushed to the iPhone client. This is开发者_JAVA技巧 this like a Watch Alert from eBay; when the bidding period of a watched item is about to close, eBay sends you a message reminding you.

What is the best way to implement this on the backend using Django? I am hesitant to use cron, because there will be a large number of events, and I do not want to schedule a cron job for each event. Additionally, I want the event notification system's model (happy to use an Adapter) to use the event queue, so that if an event is removed or updated, the event notification system will not use outdated model data.


cron is the right tool for this, but you don't want a separate cron entry for each event. Instead, cron should trigger a Django script that checks the database for any notifications that are due, and fires them.


You may want to consider Celery and its periodic scheduled tasks. Then you could schedule the tasks directly from your Python code, without having to add a crontab entry for each one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜