mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-15 09:10:32 +00:00
Add the `block_on`/`block_on_result`/`block_on_next` helpers the Postgres backend uses to drive its async `tokio-postgres` futures to completion from sync, GIL-holding Python methods, releasing the GIL for the wait. They take a `tokio::runtime::Handle` and block on it from the calling (Python) thread. Rather than give the DB backend a runtime of its own, they use the extension's existing shared runtime (`tokio_runtime::PyTokioRuntime`, stored on the reactor). `start` is made idempotent and a `runtime_handle` accessor starts it on demand, so a caller that needs a connection before the reactor is running still gets a handle; once the reactor runs, its `callWhenRunning(start)` hook is a no-op. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RPEeXx2fAG67o6u4CnmC8W