Asynchronous version of get_response. Funneling everything, including WSGI, into a single async get_response() is too slow. Avoid the context switch by using a separate async response path.
(self, request)
| 152 | return response |
| 153 | |
| 154 | async def get_response_async(self, request): |
| 155 | """ |
| 156 | Asynchronous version of get_response. |
| 157 | |
| 158 | Funneling everything, including WSGI, into a single async |
| 159 | get_response() is too slow. Avoid the context switch by using |
| 160 | a separate async response path. |
| 161 | """ |
| 162 | # Setup default url resolver for this thread. |
| 163 | set_urlconf(settings.ROOT_URLCONF) |
| 164 | response = await self._middleware_chain(request) |
| 165 | response._resource_closers.append(request.close) |
| 166 | if response.status_code >= 400: |
| 167 | await sync_to_async(log_response, thread_sensitive=False)( |
| 168 | "%s: %s", |
| 169 | response.reason_phrase, |
| 170 | request.path, |
| 171 | response=response, |
| 172 | request=request, |
| 173 | ) |
| 174 | return response |
| 175 | |
| 176 | def _get_response(self, request): |
| 177 | """ |
no test coverage detected