On Sunday, 31 May 2015 11:16:17 UTC+2, Javier Guerra wrote: > > On Sun, May 31, 2015 at 3:52 AM, Emil Stenström <[email protected] <javascript:>> > wrote: > > Could you help me understand why this have to be done inside a web > server > > container? > > AFAICT, it doesn't have to be done in the container, but currently it > must be 'outside' of Django. But having help from the container > allows a single request to be passed from one handler (a Django view) > to another (the SSE process). it might be easier if you use an URL > that goes directly to the SSE process and isn't touched by Django, but > then you need some kind of router, or 'outer url dispatcher'. unless > the SSE requests can be at a different port from the start? in that > case, the SSE process will need its own URL dispatcher. >
Since the only communication between the processes needed is to send messages, I don't think you need integration at the python level. Simply starting each process on a different port and having a way for Django to post a message to that port, would get us a long way. The SSE process would then need only one connection point, "/" if you will. Clients connect to it via a <script> tag (that's a GET), and Django posts to it via POST. > > Also, I don't think you would need to mix redis (or any other persistent > > storage) into this. The connected clients could simply be stored in an > > in-memory array, that is discarded if the server crashes. When the > server is > > started again the clients will automatically connect again, and the list > of > > clients would be built up again. > > in-memory as a Python object? but i think the SSE handler must be a > different interpreter instance... unless it's a thread... not sure if > the GIL would be an issue... or an "external" in-memory table? well, > that's what Redis is. > The idea here is to keep dependencies to a minimum. That simplifies both deployment and setup considerably. I'm thinking a simple Python array with the currently connected clients. This array would live entirely inside the new process and doesn't need to be shared with anyone. When it's time to send a message to clients you simply loop over that array and send to each client. -- 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/f0161f8f-cb82-46d8-88d7-ed70cc98cae6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
