Websockets... again

297 views
Skip to first unread message

Luis Masuelli

unread,
Oct 28, 2014, 5:06:02 PM10/28/14
to django-d...@googlegroups.com
Is there any current development involving including websockets in django core?

Aymeric Augustin

unread,
Oct 28, 2014, 5:47:31 PM10/28/14
to django-d...@googlegroups.com
No, there isn’t.

I assume that “including in core” means at least “making usable in combination with WSGI and with the ORM”.

Even if we disregard for a minute the fact that WSGI is incompatible with websockets, the ORM is a hard problem, because current solutions involve either (a) threads — not particularly scalable or (b) gevent — not particularly reliable.

-- 
Aymeric.



On 28 oct. 2014, at 22:06, Luis Masuelli <luisfm...@gmail.com> wrote:

Is there any current development involving including websockets in django core?

--
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 django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
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/50768d16-1d05-489c-8cbf-2091d95ff388%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marco Paolini

unread,
Oct 28, 2014, 6:37:15 PM10/28/14
to django-d...@googlegroups.com
What if we do it with asyncio?

Florian Apolloner

unread,
Oct 29, 2014, 3:51:40 AM10/29/14
to django-d...@googlegroups.com


On Tuesday, October 28, 2014 11:37:15 PM UTC+1, mpaolini wrote:
What if we do it with asyncio?

It is 3.4 only, WSGI still has no support for Websockets and the API would change drastically…

Aymeric Augustin

unread,
Oct 29, 2014, 4:46:15 AM10/29/14
to django-d...@googlegroups.com
Then the first step is to throw away the ORM.

See my talk at DjangoCon US 2013 for details.

-- 
Aymeric.

Collin Anderson

unread,
Oct 29, 2014, 12:35:11 PM10/29/14
to django-d...@googlegroups.com
Hi Luis,

There is some work on making a WSGI2 that would include support for http/2 and likely websockets too. That would likely need to happen first or at the same time. https://github.com/python-web-sig/wsgi-ng

You could also check out a project called "hendrix" which supports using websockets with django.

Collin


Alex Gaynor

unread,
Oct 29, 2014, 12:39:04 PM10/29/14
to django-d...@googlegroups.com
And after you throw away the ORM, you have to throw away every other library that does blocking IO (anything in the stdlib, memcached, redis, requests, etc.). There are absolutely no affordances in WSGI for use with non-blocking libraries like asyncio or Twisted.

Alex

Justin Holmes

unread,
Oct 30, 2014, 3:09:33 PM10/30/14
to django-developers
Luis,

I think what Alex and Aymeric are saying is that "websockets" (I use
quotes to show that I mean not only the material outlined in RFC 6455
but also the general process of handling bytes-on-the-wire when
'pushing' data to the 'client') are ideally not part of the problem
that Django (and WSGI applications generally) are trying to solve.
Correct me if I'm wrong, gentlemen.

Alex and Aymeric gave really stellar talks on this topic, at PyCon.us
2010 and Djangocon.us 2013 respectively, and they're really worth
going back and watching. Of course Aymeric also maintains a websocket
library (https://github.com/aaugustin/websockets).

At the end of the day, handling bytes-on-the-wire is really fun when
done on a different layer than your web MVC application. Colin
mentioned Hendrix - a Twisted container for Django. Instead of trying
to "do async" inside of WSIG, Hendrix (and some other WSGI containers)
allow you to run other python applications alongside your WSGI
application.

For example, I have a project called Cirque that uses Hendrix to both
serve a WSGI application (Django) and listen for mesh network traffic
on a UDP port. It reports mesh traffic to the Django application and
communicates directly with the websockets opened on the
Django-delivered resources.

This way, Django doesn't even need to realize that anything "async" is
happening.

It is also definitely worth paying attention to the web-sig mailing
list. As you can see, October has been mostly talk of what we want in
the next WSGI (https://mail.python.org/pipermail/web-sig/2014-October/thread.html).

This post is starting to grow beyond the django-dev topic. If you
want to know more about the how's and why's, feel free to post in
django-users. As far as django development, there seems to be no
compelling argument, at least so far, to change Django's disposition
to make it "async."
> https://groups.google.com/d/msgid/django-developers/CAFRnB2USMMbCp4r58J2zhf9HXpCAtiPYQ6UfgR%3D8Eiy%2BvC-d9w%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Peace and Persistence
jMyles
Reply all
Reply to author
Forward
0 new messages