Closed
Description
The recent 3.8.0 release causes an intermittent test failure on Django's test suite.
tests % ./runtests.py asgi.tests.ASGITest.test_disconnect_with_body
Testing against Django installed in '/Users/carlton/Projects/Django/django/django' with up to 10 processes
Found 1 test(s).
System check identified no issues (0 silenced).
F
======================================================================
FAIL: test_disconnect_with_body (asgi.tests.ASGITest.test_disconnect_with_body)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/carlton/Projects/Django/asgiref/asgiref/sync.py", line 254, in __call__
return call_result.result()
^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File ".../asgiref/sync.py", line 331, in main_wrap
result = await self.awaitable(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../django/tests/asgi/tests.py", line 374, in test_disconnect_with_body
with self.assertRaises(asyncio.TimeoutError):
AssertionError: TimeoutError not raised
----------------------------------------------------------------------
Ran 1 test in 0.005s
FAILED (failures=1)
This tests disconnect handling for a request with a body. The main task processing the request is not correctly cancelled, on some runs only. (The assertion fails, with response content {'type': 'http.response.start', 'status': 200, 'headers': [(b'Content-Type', b'text/html; charset=utf-8'), (b'Content-Length', b'12')]}
delivered, rather than the timeout.)
Bisected to 0503c2c by @ttys0dev for #435.
0503c2c4df06dbe56f04689fe537325f28dbbe8b is the first bad commit
commit 0503c2c4df06dbe56f04689fe537325f28dbbe8b
Author: ttys0dev <126845556+ttys0dev@users.noreply.github.com>
Date: Fri Jan 26 23:13:55 2024 -0700
Fix task cancellation propagation to subtasks when using sync middleware (#435)
asgiref/sync.py | 59 +++++++++++++++-----
tests/test_sync.py | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 201 insertions(+), 17 deletions(-)
//cc @felixxm