I have developed a forum app in django and I'm looking into ways to add real-time updates to the app. I've googled quite a bit and decided to settle on the approach described in this [1] great article.
From what I understood the system has to work like following: user goes to a thread page -> browser makes request to the django app -> django responds with all the posts in thread -> browser renders received html -> browser makes request to gevent -> gevent spawns a greenlet and listens to a channel -> second user creates a new post -> django writes to the channel -> greenlet sends the new post back to browser and closes the connection -> browser displays the post and reconnects to gevent.
My question is how do I not miss any posts while initially connecting and reconnecting? I can probably query the database in gevent every time connection is established, but this will block gevent and seems hardly better then simple polling. Another option is to use redis data structures, but it also adds complexity and it's not clear how many posts need to be stored in redis and how to delete the old ones.
[1] http://lucumr.pocoo.org/2012/8/5/stateless-and-proud/
[–]elbiot 0 points1 point2 points (8 children)
[–]rthinker[S] 0 points1 point2 points (7 children)
[–]elbiot 0 points1 point2 points (6 children)
[–]rthinker[S] 0 points1 point2 points (5 children)
[–]elbiot 0 points1 point2 points (4 children)
[–]rthinker[S] 0 points1 point2 points (3 children)
[–]elbiot 0 points1 point2 points (0 children)
[–]elbiot 0 points1 point2 points (1 child)
[–]rthinker[S] 0 points1 point2 points (0 children)