Infinite HttpStreamingResponse Doesn't work with websocket on channels asgi

73 views
Skip to first unread message

erfan faraj

unread,
Mar 17, 2021, 1:41:24 PM3/17/21
to Django users

Hello,

I ran into an issue with channels asgi today. I had a wsgi server which i implemented with django and django rest framework. the server streams video from a webcam indefinitly and at the same time listens for requests like save image which saves a frame on the server or stops and starts the stream. this worked fine. at the same time as the livestream i could do requests. but when i added asgi to my application so i could use the websocket feature for notifications, it stopped working. when i start the stream i can do no other request, even the websocket doesn't work. what should i do?

Ryan Nowakowski

unread,
Mar 17, 2021, 2:03:49 PM3/17/21
to django...@googlegroups.com
I haven't messed much with Django async. Could your video streaming view be blocking the asgi run loop?

erfan faraj

unread,
Mar 17, 2021, 2:15:20 PM3/17/21
to Django users
you mean the event loop?

Ryan Nowakowski

unread,
Mar 17, 2021, 4:40:41 PM3/17/21
to Django users
> you mean the event loop?

Yup

erfan faraj

unread,
Mar 17, 2021, 4:42:26 PM3/17/21
to Django users
I would think so but why should it? it didn't do that in the wsgi version. what happens behind the scenes in wsgi that causes it to not block other requests

Ryan Nowakowski

unread,
Mar 17, 2021, 4:58:44 PM3/17/21
to Django users
On Wed, Mar 17, 2021 at 09:42:26AM -0700, erfan faraj wrote:
> On Wednesday, March 17, 2021 at 8:10:41 PM UTC+3:30 Ryan Nowakowski wrote:
> > On Wed, Mar 17, 2021 at 07:15:20AM -0700, erfan faraj wrote:
> > > On Wednesday, March 17, 2021 at 5:33:49 PM UTC+3:30 Ryan Nowakowski
> > wrote:
> > > >
> > > > I haven't messed much with Django async. Could your video streaming
> > view
> > > > be blocking the asgi run loop?
> > > >
> > > you mean the event loop?
> >
> > Yup
> >
> I would think so but why should it? it didn't do that in the wsgi version.
> what happens behind the scenes in wsgi that causes it to not block other
> requests

Perhaps your wsgi server uses a thread per request but your asgi server
doesn't? Again, I'm just hypothesizing since I really haven't done
much with async. I'll probably shut up now and let someone with actual
knowledge step in ;)
Reply all
Reply to author
Forward
0 new messages