﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34998	Raising a StopIteration in asynchronous mode hangs the request	Clément Escolano	nobody	"When using Django in Asynchronous mode, if some code raises a `StopIteration` error (generally when calling `next()` on an empty generator), the request hangs. I think Django should handle the error gracefully (display a 500 error page) instead.

Basically, when the code raises a `StopIteration` error, the following is displayed and the request hangs:

{{{
TypeError: StopIteration interacts badly with generators and cannot be raised into a Future
}}}

I have reproduce the issue with a minimal project here: https://github.com/clement-escolano/django-stopiteration

Relevant file is `stopiteration/views.py` which is a view called on `/error` endpoint and contains:

{{{
def error(request):
    next(i for i in [])
    return None
}}}

The Django application must be run with asynchronous support. For instance with: `uvicorn test_stopiteration.asgi:application`."	Cleanup/optimization	closed	Core (Other)	4.2	Normal	wontfix		Carlton Gibson Andrew Godwin	Unreviewed	0	0	0	0	0	0
