SQLAlchemy MissingGreenlet: greenlet_spawn has not been called

Triggered implicit synchronous lazy-load inside an `AsyncSession` query.

Runs locally in browser Free · No login Independently Verified 2026-11-25 v4.1.0
Identifier: SQLAlchemy MissingGreenlet Platform: Python
Common Root Causes:
  • Triggered implicit synchronous lazy-load inside an `AsyncSession` query.

Interactive Diagnostic Checklist

Verified Solutions:
  1. Always use explicit `selectinload()` or `awaitable_attrs` with SQLAlchemy AsyncIO.
Safe Diagnostic Command:
Inspect relationship access after `await session.execute()`
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.

Technical Explanation

Triggered implicit synchronous lazy-load inside an `AsyncSession` query. Recommended diagnostic: `Inspect relationship access after `await session.execute()``. Remediation: Always use explicit `selectinload()` or `awaitable_attrs` with SQLAlchemy AsyncIO.

Worked Examples

  • Run `Inspect relationship access after `await session.execute()`` to verify root cause before applying the remediation.

Limitations & Assumptions

  • Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.

Source References & Verification

Resource ID: err-py-sqlalchemy-greenlet-missing-async · Independently verified: 2026-11-25

Related Resources