question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Static Files Error With The Latest Version (3.3.2)

See original GitHub issue

There seems to be something wrong with serving static files in the latest version, this is the error:

raise TypeError("async_to_sync can only be applied to async functions.")
TypeError: async_to_sync can only be applied to async functions.
HTTP GET /static/rest_framework/js/default.js 500 [1.01, 127.0.0.1:50017]

The previous version (3.3.1) works perfectly

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
BeryJucommented, Apr 6, 2021

I also just ran into this issue, same error message:

Traceback (most recent call last):
  File "/Users/langhammerj/.local/share/virtualenvs/authentik-fAhVAmau/lib/python3.9/site-packages/channels/staticfiles.py", line 40, in __call__
    return await self.staticfiles_handler_class()(
  File "/Users/langhammerj/.local/share/virtualenvs/authentik-fAhVAmau/lib/python3.9/site-packages/channels/staticfiles.py", line 56, in __call__
    return await super().__call__(scope, receive, send)
  File "/Users/langhammerj/.local/share/virtualenvs/authentik-fAhVAmau/lib/python3.9/site-packages/channels/http.py", line 198, in __call__
    await self.handle(scope, async_to_sync(send), body_stream)
  File "/Users/langhammerj/.local/share/virtualenvs/authentik-fAhVAmau/lib/python3.9/site-packages/asgiref/sync.py", line 105, in __init__
    raise TypeError("async_to_sync can only be applied to async functions.")
TypeError: async_to_sync can only be applied to async functions.

(In my case, using Django 3.1.7, asgiref 3.3.2, python 3.9.2 and channels 3.0.3, and downgrading to 3.3.1 fixes it here too)

Oh, and the error also happens if I disable channels and only use django’s get_asgi_application()

1reaction
andrewgodwincommented, Apr 7, 2021

Yes, let’s take the time and do this properly. Given we know that partial works and is accounted for in both python and asgiref, I think I’d go with that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django channels error when attempting to serve static files ...
I added asgiref==3.2.10 to my requirements.txt file and it seems to have solved the problem.
Read more >
Daphne raises Internal Server Error when accessing static ...
This error raises every time a file from static folder is accessed. What would be a proper way for debugging this? I've got...
Read more >
Static File Errors With New Version of Django - YouTube
Django recently updated to version 3.1 and now we need to make a change to our settings.py file to deal with our static...
Read more >
Try Django 1.9 - 25 of 38 - Setup Static Files - CSS ... - YouTube
... of 38 - Setup Static Files - CSS & Javascript & Images in Django** Try Django 1.9 ** is an introduction to...
Read more >
Django Static Files Handling made Simple - DataFlair
First, create a new folder template in the home app. Inside that folder, create two new files, base.html, and others.html. Then just paste...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found