mirror of
https://github.com/element-hq/synapse.git
synced 2026-04-02 18:56:01 +00:00
awaitable and handles each appropriately: - Twisted Deferred: synchronously adds logcontext callbacks (classic behavior, 100% backward compatible) - Native awaitable (asyncio.Future, coroutine): returns an async wrapper that saves/restores logcontext This means the migration can be incremental — code that still uses Deferreds works unchanged, while new code using native awaitables also works. The make_deferred_yieldable function becomes the bridge. The same pattern applies to run_in_background — it already handles both Deferreds and coroutines (via defer.ensureDeferred). It doesn't need to change. This is a much better approach than the "flag day" — it allows gradual migration of individual subsystems from Deferred→asyncio without breaking anything.