test(django): Remove forking in ASGI tests#6410
Merged
Merged
Conversation
Contributor
Codecov Results 📊✅ 79 passed | Total: 79 | Pass Rate: 100% | Execution Time: 909ms All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 16035 uncovered lines. Generated by Codecov Action |
52b8273 to
cd5adf7
Compare
cd5adf7 to
587611d
Compare
sl0thentr0py
commented
May 26, 2026
| - op="middleware.django": description="django.middleware.csrf.CsrfViewMiddleware.process_view" | ||
| - op="view.render": description="simple_async_view" | ||
| - op="event.django": description="django.db.close_old_connections" | ||
| - op="event.django": description="django.core.cache.close_caches" |
Member
Author
There was a problem hiding this comment.
the ordering of these is now non-deterministic so I'm simply removing checking them now, not what this test is about and they're tested elsewhere
Member
Author
|
agents failure unrelated |
alexander-alderman-webb
approved these changes
May 26, 2026
The ASGI test suite uses @pytest.mark.forked + @pytest.mark.asyncio. On Python 3.12 in GitHub Actions' multi-threaded runner, pytest-forked forks a multi-threaded process; the asyncio event loop in the child inherits dead threads, causing silent hangs that consume the full CI budget. Drop @pytest.mark.forked from all 10 affected tests — the sentry_init fixture already handles SDK state save/restore correctly without forking. Three of those tests called asgi_application.load_middleware(is_async=True), which mutates the shared module-level asgi_application instance and leaks state into subsequent tests. Introduce a make_asgi_application fixture that returns get_asgi_application so tests can build a fresh app after sentry_init (ensuring middleware instrumentation is installed before Django builds the chain). Also replace the deprecated asyncio.get_event_loop() pattern in the concurrent execution tests with asyncio.gather(). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
587611d to
2677349
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drop
@pytest.mark.forkedfrom the Django ASGI test suite and stop mutating the module-levelasgi_applicationinstance. On Python 3.12 in GitHub Actions' multi-threaded runner,pytest-forkedforks a multi-threaded process; the asyncio event loop in the child inherits dead threads and silently hangs, consuming the full CI budget.Removed
@pytest.mark.forkedRemoved from all 10 affected tests. The
sentry_initfixture already handles SDK state save/restore correctly without forking.Fresh ASGI app per test
Three tests called
asgi_application.load_middleware(is_async=True), which mutates the shared module-level instance and leaks state into subsequent tests. They now use a newmake_asgi_applicationfixture that returnsget_asgi_application— letting tests build a fresh app aftersentry_init, so middleware instrumentation is installed before Django builds the chain.Concurrent execution tests
Replaced the deprecated
asyncio.get_event_loop()+create_taskpattern withasyncio.gather().Issues