django / channels

Developer-friendly asynchrony for Django
https://channels.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6k stars 793 forks source link

Django 3.0 vs. Channels? #1416

Open bluesurfer opened 4 years ago

bluesurfer commented 4 years ago

Django 3 has start the road to asynchrony. I am kind of confused about the future of this (great) library and how it will play along with Django 3.

Is this library going to be integrated inside Django 3? Or will it be deprecated in favour of new Django 3 implementations?

jheld commented 4 years ago

This is a great question.

My take (my project uses django channels extensively in production), is that it might be the sort of thing where DRF (django rest framework), requests, etc, do not plan (or try) to get into the core of the project they're used for. If they do get integrated, the release cadence will likely be slower. That doesn't mean channels etc are not stable currently!

The async/ASGI road-map is medium to long term, so I'd imagine (I'm neither a fortune-teller nor a core dev on either project) that the consideration for integration/semantic porting would be after most of the heavy lifting on the django side is complete. Thinking: async middleware, views, ORM, caching, etc. And channels itself having the ability to use redis or other tech for unicast/broadcast flows -- something that has traditionally been very much outside of django's purview and more inline with a task queuing framework like celery (asyncio or not).

My project uses the synchronous websocket consumer (mostly due to the ORM issues) and as such, if django were to implement a synchronous websocket consumer, that's probably easier than getting the tooling for full async working.

That said, that's my take as I both develop against this library, and what I'm reading/hearing.

Would be awesome to get feedback/clarity/potential plans from contributors/maintainers here.

carltongibson commented 4 years ago

It's early days yet. But, in theory, we could embed Django exactly as we currently do, except Django's own ASGIHandler, rather than Channel's version. Then our websockets and such will run along-side. That's the first phase. Updating Channels to ASGIv3 is probably needed there.

Beyond that it's difficult to know. Channels had Consumers, which are ASGI apps, where Django will have async def views, very similar to what we already have.

The other two bits are the websockets, which at least for now, we'll keep here, and the channel layers, which I don't see a great rush to move into Django either.

It'll be interesting how Django evolves (currently it doesn't look like middleware will be ASGI middleware... — so there's different layers there).

leonardfreitas commented 4 years ago

I still don't understand, but currently to use websocket with django is it still better to use channels?

carltongibson commented 4 years ago

@leonardfreitas Yes. Currently (probably for the medium term at least) if you want websocket support use Channels.

ddahan commented 3 years ago

I asked for a similar question on Stack Overflow (didn't notice this issue at the time), and I like to point out that good answer too :)

johnthagen commented 3 years ago

Is there any documentation on the current roadmap of async functionality planned for Django 3.2 or 4.0? I remember the original roadmap from 2018 being really helpful and was curious if there is an updated one now that we are nearing the end of 2020.