Start and stop the Tokio runtime with the Twisted reactor (#18691)

Fixes https://github.com/element-hq/synapse/issues/18659

This changes the Tokio runtime to be attached to the Twisted reactor.
This way, the Tokio runtime starts when the Twisted reactor starts, and
*not* when the module gets loaded.

This is important as starting the runtime on module load meant that it
broke when Synapse was started with `daemonize`/`synctl`, as forks only
retain the calling threads, breaking the Tokio runtime.

This also changes so that the HttpClient gets the Twisted reactor
explicitly as parameter instead of loading it from
`twisted.internet.reactor`
This commit is contained in:
Quentin Gliech
2025-07-17 17:15:11 +02:00
committed by GitHub
parent a0d6469069
commit f031105eee
6 changed files with 164 additions and 73 deletions

1
Cargo.lock generated
View File

@@ -1470,6 +1470,7 @@ dependencies = [
"lazy_static",
"log",
"mime",
"once_cell",
"pyo3",
"pyo3-log",
"pythonize",