Opened 4 years ago
Last modified 4 years ago
#31984 closed Bug
Uvicorn + Django: TypeError: object HttpResponse can't be used in 'await' expression — at Version 2
Reported by: | Aaron Ng | Owned by: | nobody |
---|---|---|---|
Component: | HTTP handling | Version: | 3.1 |
Severity: | Normal | Keywords: | asgi, uvicorn |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
It seems like running Django with an asgi server like uvicorn in 3.1 causes TypeError: object HttpResponse can't be used in 'await' expression
to be raised. Runserver works fine, as does gunicorn + wsgi. This is happening across two different projects for me.
[2020-09-05 15:34:28 -0700] [93779] [INFO] Booting worker with pid: 93779 [2020-09-05 15:34:28 -0700] [93780] [INFO] Booting worker with pid: 93780 [2020-09-05 15:34:28 -0700] [93781] [INFO] Booting worker with pid: 93781 [2020-09-05 15:34:28 -0700] [93782] [INFO] Booting worker with pid: 93782 [2020-09-05 22:34:30 +0000] [93780] [INFO] Started server process [93780] [2020-09-05 22:34:30 +0000] [93781] [INFO] Started server process [93781] [2020-09-05 22:34:30 +0000] [93782] [INFO] Started server process [93782] [2020-09-05 22:34:30 +0000] [93779] [INFO] Started server process [93779] Internal Server Error: /users/self/ Traceback (most recent call last): File "/Users/james/Github/oregano-server/.venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/Users/james/Github/oregano-server/.venv/lib/python3.7/site-packages/django/utils/deprecation.py", line 116, in __call__ response = self.process_response(request, response) File "/Users/james/Github/oregano-server/.venv/lib/python3.7/site-packages/django/middleware/clickjacking.py", line 26, in process_response if response.get('X-Frame-Options') is not None: AttributeError: 'coroutine' object has no attribute 'get' 2020-09-05 22:35:03,901 ERROR Internal Server Error: /users/self/ Traceback (most recent call last): File "/Users/james/Github/oregano-server/.venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/Users/james/Github/oregano-server/.venv/lib/python3.7/site-packages/django/utils/deprecation.py", line 116, in __call__ response = self.process_response(request, response) File "/Users/james/Github/oregano-server/.venv/lib/python3.7/site-packages/django/middleware/clickjacking.py", line 26, in process_response if response.get('X-Frame-Options') is not None: AttributeError: 'coroutine' object has no attribute 'get' Internal Server Error: /users/self/ Traceback (most recent call last): File "/Users/james/Github/oregano-server/.venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/Users/james/Github/oregano-server/.venv/lib/python3.7/site-packages/asgiref/sync.py", line 139, in __call__ return call_result.result() File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 428, in result return self.__get_result() File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result raise self._exception File "/Users/james/Github/oregano-server/.venv/lib/python3.7/site-packages/asgiref/sync.py", line 204, in main_wrap result = await self.awaitable(*args, **kwargs) TypeError: object HttpResponse can't be used in 'await' expression 2020-09-05 22:35:03,982 ERROR Internal Server Error: /users/self/ Traceback (most recent call last): File "/Users/james/Github/oregano-server/.venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/Users/james/Github/oregano-server/.venv/lib/python3.7/site-packages/asgiref/sync.py", line 139, in __call__ return call_result.result() File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 428, in result return self.__get_result() File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result raise self._exception File "/Users/james/Github/oregano-server/.venv/lib/python3.7/site-packages/asgiref/sync.py", line 204, in main_wrap result = await self.awaitable(*args, **kwargs) TypeError: object HttpResponse can't be used in 'await' expression
Change History (2)
comment:1 by , 4 years ago
Description: | modified (diff) |
---|
comment:2 by , 4 years ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.