# Diagnose: Django on uWSGI, workers crashing or Sentry half-dead

## The symptom

Either uWSGI workers crash and restart in a loop, or Sentry partially works: some events arrive, tracing data is missing, breadcrumbs stop. Everything is fine under `runserver` locally.

## The cause

uWSGI does not support threads by default, and the Sentry SDK depends on background threads for its transport and several features. The docs describe the range: from features not working properly to uWSGI workers crashing.

## The fix

Both flags are required:

```
uwsgi --enable-threads --py-call-uwsgi-fork-hooks ...
```

`--enable-threads` alone is not enough; the fork hooks matter because uWSGI forks workers after the master loads, and thread state does not survive the fork without them.

## Confirmation

Check the process invocation (systemd unit, Docker CMD, ini file) for both flags. Then watch worker behavior: crashes stopping after adding the flags confirms the diagnosis. If you use an ini file, the equivalents are `enable-threads = true` and `py-call-uwsgi-fork-hooks = true`.

## If it persists

Some builds of uWSGI have threading quirks regardless of flags. If crashes continue with both flags set, test with gunicorn (sync or gevent workers) to isolate whether it is uWSGI-specific. Also confirm you are not running with `--lazy` or `--lazy-apps` in a way that initializes the SDK per worker without the fork hooks.

## Verify

Workers stay up under load, and a full request produces both the error event and its trace with DB spans. The uWSGI log should show no worker respawn storms after the change.