Commit Graph

25 Commits

Author SHA1 Message Date
Carlton Gibson f4a08b6ddf
Refs #35059 -- Used asyncio.Event in ASGITest.test_asyncio_cancel_error to enforce specific interleaving.
Sleep call leads to a hard to trace error in CI. Using an Event is
more deterministic, and should be less prone to environment
variations.

Bug in 11393ab131.
2024-05-28 14:36:34 -03:00
James Thorniley 11393ab131 Fixed #35059 -- Ensured that ASGIHandler always sends the request_finished signal.
Prior to this work, when async tasks that process the request are cancelled due
to receiving an early "http.disconnect" ASGI message, the request_finished
signal was not being sent, potentially leading to resource leaks (such as
database connections).

This branch ensures that the request_finished signal is sent even in the case
of early termination of the response.

Regression in 64cea1e48f.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
2024-01-31 14:40:57 -03:00
Natalia a43d75e81d Refs #35059 -- Made asgi tests' SignalHandler helper class re-usable by other tests. 2024-01-31 14:39:40 -03:00
Mariusz Felisiak d88ec42bd0
Used addCleanup() in tests where appropriate. 2023-12-31 10:01:31 +01:00
Sam Toyer 64cea1e48f Fixed #34752 -- Fixed handling ASGI http.disconnect for streaming responses. 2023-09-11 19:53:21 +02:00
th3nn3ss 1d1ddffc27 Fixed #33738 -- Allowed handling ASGI http.disconnect in long-lived requests. 2023-04-03 14:01:48 +02:00
Carlton Gibson 02c356f2f3
Fixed #34428 -- Made ASGIStaticFilesHandler adapt response to async iterator.
Bug in 0bd2c0c901.
2023-03-21 20:51:53 +01:00
Liyang Zhang f9f9215d3e
Fixed some typos in comments, docstrings, and tests. 2023-03-20 08:07:23 +01:00
Carlton Gibson 0bd2c0c901 Fixed #33735 -- Added async support to StreamingHttpResponse.
Thanks to Florian Vazelle for initial exploratory work, and to Nick
Pope and Mariusz Felisiak for review.
2022-12-22 10:41:12 +01:00
Carlton Gibson f476c8847a Refs #33173, Refs #33755 -- Fixed ResourceWarning from unclosed files in ASGI tests. 2022-08-04 10:00:36 +02:00
Jonas Lundberg e96320c917 Fixed #33755 -- Moved ASGI body-file cleanup into request class. 2022-06-09 11:11:45 +02:00
Jonas Lundberg f1e0fc645b Fixed #33754 -- Fixed crash with prematurely closed ASGI request body.
Regression in 441103a04d.
2022-05-31 08:38:00 +02:00
Carlton Gibson 5c67d906fd Removed stale Windows asyncio test skips.
Underlying issue was fixed in Python 3.8.1, now many versions ago.
https://bugs.python.org/issue38563
2022-04-14 10:43:34 +02:00
django-bot 9c19aff7c7 Refs #33476 -- Reformatted code with Black. 2022-02-07 20:37:05 +01:00
Allan Feldman 36fa071d6e Fixed #32889 -- Allowed per-request sync_to_async context in ASGIHandler .
By using a asgiref's ThreadSensitiveContext context manager, requests
will be able to execute independently of other requests when sync work
is involved.

Prior to this commit, a single global thread was used to execute any
sync work independent of the request from which that work was scheduled.
This could result in contention for the global sync thread in the case
of a slow sync function.

Requests are now isolated to their own sync thread.
2021-07-01 12:13:19 +02:00
Markus Holtermann 50a5f8840f Refs #32394 -- Changed STATIC_URL/MEDIA_URL to relative paths in tests and docs where appropriate. 2021-02-06 13:41:35 +01:00
Christopher Keith 76181308fb
Fixed #31550 -- Adjusted ASGI test_file_response for various Windows content types. 2020-11-05 08:18:45 +01:00
Joshua Massover 92309e53d9 Fixed #31594 -- Added ASGIStaticFilesHandler.get_response_async(). 2020-06-08 12:52:26 +02:00
Carlton Gibson 92507bf3ea Fixed #31515 -- Made ASGIHandler dispatch lifecycle signals with thread sensitive. 2020-05-06 09:42:02 +02:00
Andrew Godwin fc0fa72ff4 Fixed #31224 -- Added support for asynchronous views and middleware.
This implements support for asynchronous views, asynchronous tests,
asynchronous middleware, and an asynchronous test client.
2020-03-18 19:59:12 +01:00
Andrew Godwin 17009e9105 Refs #31224 -- Added autoconversion of test async methods. 2020-03-05 14:29:21 +01:00
Jon Dufresne 39791c8e6d Harmonized Windows checks in tests to a single style. 2019-11-06 15:14:30 +01:00
Carlton Gibson e83c300a33 Fixed #30900 -- Skipped async-related tests on Windows using Python 3.8.0.
Refs https://bugs.python.org/issue38563.
2019-10-24 10:43:05 +02:00
Mariusz Felisiak 7f19e37135 Refs #30451 -- Added more tests for ASGIRequest and ASGIHandler. 2019-06-20 12:29:58 +02:00
Andrew Godwin a415ce70be Fixed #30451 -- Added ASGI handler and coroutine-safety.
This adds an ASGI handler, asgi.py file for the default project layout,
a few async utilities and adds async-safety to many parts of Django.
2019-06-20 12:29:43 +02:00