Skip to content

Commit

Permalink
self review
Browse files Browse the repository at this point in the history
  • Loading branch information
Archmonger committed Aug 27, 2024
1 parent 92f4884 commit 3b37902
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ Using the following categories, list your changes in this order:

## [Unreleased]

- Nothing (yet)!
- Prevent responses with no body from creating a warning by providing Django an empty async iterable as the file content.
- Force Django>=3.2 to use async file responses if possible, regardless of whether the middleware is run in sync or async mode.

## [1.0.0] - 2024-05-08

Expand Down
10 changes: 5 additions & 5 deletions src/servestatic/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __call__(self, request):
if iscoroutinefunction(self.get_response):
return self.acall(request)

# Force Django >= 3.2 use async file responses when using ASGI, even
# Allow Django >= 3.2 to use async file responses when running via ASGI, even
# if Django forces this middleware to run synchronously
if django.VERSION >= (3, 2):
return asyncio.run(self.acall(request))
Expand All @@ -171,8 +171,8 @@ def __call__(self, request):
return self.call(request)

def call(self, request):
"""If the URL contains a static file, serve it.
Otherwise, continue to the next middleware."""
"""If the URL contains a static file, serve it. Otherwise, continue to the next
middleware."""
if self.autorefresh:
static_file = self.find_file(request.path_info)
else:
Expand All @@ -184,8 +184,8 @@ def call(self, request):
return self.get_response(request)

async def acall(self, request):
"""If the URL contains a static file, serve it.
Otherwise, continue to the next middleware."""
"""If the URL contains a static file, serve it. Otherwise, continue to the next
middleware."""
if self.autorefresh and hasattr(asyncio, "to_thread"):
# Use a thread while searching disk for files on Python 3.9+
static_file = await asyncio.to_thread(self.find_file, request.path_info)
Expand Down

0 comments on commit 3b37902

Please sign in to comment.