getsentry / getsentry/sentry

thread leak in test: django dev server

Open
#98,988 1 comment 0 reactions 0 assignees View on GitHub
GitHub Team: dev-infra Tests
Dominant language
Python
Stars
44.8k
Forks
4.9k
Avg merge
22h 21m
Merged PRs (30d)
586

Description

# Thread leak: Django Dev Server

📋 **Complete fix guidance**: [How-To: Thread Leaks](How-To-Thread-Leaks.md)

The django "dev server" is starting during test but not being cleaned up.

## Reproduction

To reproduce the thread leak:

1. Remove the `@thread_leak_allowlist` decorator from the test if present
2. Run:

```bash
export SENTRY_THREAD_LEAK_STRICT=1
pytest -v tests/acceptance/test_disabled_custom_symbol_sources.py::DisabledCustomSymbolSourcesSettingsTest::test_disabled_custom_symbol_sources
```

## Example Thread Leaks

```
@django.core.servers.basehttp.ThreadedWSGIServer.process_request_thread
```

## Verify Fix

Remove any `@thread_leak_allowlist` decorators and confirm no failures:

```bash
export SENTRY_THREAD_LEAK_STRICT=1
pytest -v tests/acceptance/test_disabled_custom_symbol_sources.py
```

## Impact
- Tests: 295
- Files:

Contributor guide

Open the contributing guide

Research direction

Read How-To-Thread-Leaks.md, then reproduce the leak with tests/acceptance/test_disabled_custom_symbol_sources.py::DisabledCustomSymbolSourcesSettingsTest::test_disabled_custom_symbol_sources and SENTRY_THREAD_LEAK_STRICT=1. Trace the Django dev server thread shown in the failure and identify the cleanup path. Done means the allowlist decorator is unnecessary and the full test file passes without thread-leak failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.