mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #31407 -- Adjusted test to avoid coroutine never awaited warning.
This commit is contained in:
parent
26799c6503
commit
590957a0eb
2 changed files with 13 additions and 6 deletions
|
@ -51,6 +51,12 @@ async def async_regular(request):
|
|||
return HttpResponse(b'regular content')
|
||||
|
||||
|
||||
async def async_unawaited(request):
|
||||
"""Return an unawaited coroutine (common error for async views)."""
|
||||
return asyncio.sleep(0)
|
||||
class CoroutineClearingView:
|
||||
def __call__(self, request):
|
||||
"""Return an unawaited coroutine (common error for async views)."""
|
||||
# Store coroutine to suppress 'unawaited' warning message
|
||||
self._unawaited_coroutine = asyncio.sleep(0)
|
||||
return self._unawaited_coroutine
|
||||
|
||||
|
||||
async_unawaited = CoroutineClearingView()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue