Skip to content

Commit

Permalink
Solve static files deadlock bug for django 3.0+ (django#1722)
Browse files Browse the repository at this point in the history
  • Loading branch information
sterliakov committed Feb 8, 2022
1 parent 08c9315 commit f9867e9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions channels/staticfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
from django.contrib.staticfiles.views import serve
from django.http import Http404

from .http import AsgiHandler
try:
from django.core.handlers.asgi import ASGIHandler
except ImportError:
from .http import AsgiHandler as ASGIHandler


class StaticFilesWrapper:
Expand Down Expand Up @@ -44,7 +47,7 @@ async def __call__(self, scope, receive, send):
return await self.application(scope, receive, send)


class StaticFilesHandler(AsgiHandler):
class StaticFilesHandler(ASGIHandler):
"""
Subclass of AsgiHandler that serves directly from its get_response.
"""
Expand All @@ -68,7 +71,7 @@ def serve(self, request):
"""
return serve(request, self.file_path(request.path), insecure=True)

def get_response(self, request):
async def get_response_async(self, request):
"""
Always tries to serve a static file as you don't even get into this
handler subclass without the wrapper directing you here.
Expand Down

1 comment on commit f9867e9

@vercel
Copy link

@vercel vercel bot commented on f9867e9 Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

channels – ./

channels-three.vercel.app
channels-sterliakov.vercel.app
channels-git-main-sterliakov.vercel.app

Please sign in to comment.