What’s the easiest way to take an existing Django view and make it “real time” via long polling?
2nd October 2010
My answer to What’s the easiest way to take an existing Django view and make it “real time” via long polling? on Quora
I’d advocate decoupling your long polling endpoints entirely from the rest of your web app stack. Personally I like Node.js for this, but Tornado would work just fine too (I’ve experimented successfully with Tornado long polling in the past).
I wouldn’t even bother talking to the database from the long polling code. Instead, set it up as a sort of WebHook system. Your client starts long-polling a URL on the Tornado or Node.js server (which could be running on a sub-domain of your regular site, or could just be a separate part of the URL space proxied by something like nginx). That long polling server is set up to listen for WebHook POSTs to a protected URL, which can come from a backend process, a Celery worker, a Cron job or the Django web app itself. When the POST comes in, the long poll is instantly returned.
More recent articles
- Qwen2.5-Coder-32B is an LLM that can code well that runs on my Mac - 12th November 2024
- Visualizing local election results with Datasette, Observable and MapLibre GL - 9th November 2024
- Project: VERDAD - tracking misinformation in radio broadcasts using Gemini 1.5 - 7th November 2024