On Sat, May 30, 2015 at 4:19 PM, Florian Apolloner <[email protected]> wrote: > ie how would it use Django's current featureset which is basically blocking > everywhere…
On Sat, May 30, 2015 at 4:40 PM, Emil Stenström <[email protected]> wrote: > The separate process would have none of Django's features, it would just be > a way to send messages to connected clients. take a look on how it's done with uWSGI: [1]. Basically, the http request arrives to a Django view in the normal way; then it generates a response with a custom header, which the uWSGI system recognizes (much like X-Sendfile), and routes the request to a gevent-based wsgi app that uses an sse package (probably [2]) to keep the connection. in the given example, there's no further communication between Django and the SSE process, but the author then comments it could be done either with the uWSGI caching framework, or via Redis. If I were to implement this today (and in fact, i have an application that might need this in the near future), i would use basically this scheme (as I'm using uWSGI for all my deployments), and Redis. The SSE process would keep in Redis the current set of connected users, and the Django process would send messages via Redis to the SSE process. Of course, not only 'broadcast' messages to every connected user, but user-specific messages too. I don't see how would i do it for a reusable app, since it looks most of the code would run 'outside' Django. Doing it for the Django core seems even more problematic, since it would also have to be much more flexible in requirements, both for the WSGI container (does mod_wsgi support async python code? i guess gunicorn does), and also for the communications between the 'main' Django views and the SSE part. (probably the cache API would be appropriate) [1]: https://uwsgi-docs.readthedocs.org/en/latest/articles/OffloadingWebsocketsAndSSE.html [2]: https://github.com/niwinz/sse -- Javier -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAFkDaoSSZGZcPsNEomS5%2BPnSAVP6LLmbEcSO5Epu01t6UsxKXg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
