# ERROR at teardown of test_foo
RuntimeError: generator didn't stop after throw()

- **ID:** `python/pytest-session-fixture-finalizer-error`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A yield-based fixture raised an exception inside its teardown after the yield, and the generator did not catch it, so pytest's finalizer machinery reports the generator as still running.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (92% success)
   ```
   @pytest.fixture
def client():
    c = connect()
    try:
        yield c
    finally:
        try:
            c.close()
        except Exception as e:
            log.warning('close failed: %s', e)
   ```
2. **** (90% success)
   ```
   @pytest.fixture
def client(request):
    c = connect()
    request.addfinalizer(c.close)
    return c
   ```

## Dead Ends

- **** — The error occurs during fixture teardown, outside the test body, so the test's try/except never sees it. (80% fail)
- **** — Loses teardown entirely; resources are never released and the error is replaced by a leak. (70% fail)
