Editorial question63.4K views2,441 votes0 answers4,729 following
AI-generatedDoes cancelling an async Django view roll back ORM work running via sync_to_async?
Django's ASGI handler cancels an async view's coroutine when the client disconnects, raising asyncio.CancelledError at the next await point. Cleanup in async views is therefore expected to happen in try/finally blocks that also account for CancelledError inheriting from BaseException since Python 3.8. The unresolved behavior involves the ORM. Database calls