Skip to content

Split out deferred and tokio_runtime to their own Rust modules#19868

Merged
MadLittleMods merged 5 commits into
developfrom
madlittlemods/deferred-and-tokio-runtime-crates
Jun 20, 2026
Merged

Split out deferred and tokio_runtime to their own Rust modules#19868
MadLittleMods merged 5 commits into
developfrom
madlittlemods/deferred-and-tokio-runtime-crates

Conversation

@MadLittleMods

@MadLittleMods MadLittleMods commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Split out deferred and tokio_runtime to their own Rust modules

Spawning from #19824 / #19846 and wanting to use create_deferred in more than just the http_client.rs

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct (run the linters)

Comment thread rust/src/deferred.rs
@@ -0,0 +1,140 @@
/*

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a case of copy-pasting stuff from rust/src/http_client.rs

Comment thread rust/src/deferred.rs
Comment on lines +132 to +140
/// Called when registering modules with python.
pub fn register_module(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
_ = m;

// Make sure we fail early if we can't load some modules
defer(py)?;

Ok(())
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The register_module(...) is new but the functionality is pulled from the register_module(...) from rust/src/http_client.rs

Comment thread rust/src/tokio_runtime.rs
@@ -0,0 +1,107 @@
/*

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a case of copy-pasting stuff from rust/src/http_client.rs

@MadLittleMods MadLittleMods marked this pull request as ready for review June 19, 2026 05:53
@MadLittleMods MadLittleMods requested a review from a team as a code owner June 19, 2026 05:53
Comment thread changelog.d/19868.misc Outdated
Comment thread rust/src/deferred.rs Outdated
Comment thread rust/src/deferred.rs
use crate::tokio_runtime::runtime;

create_exception!(
synapse.synapse_rust.http_client,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a bit weird to have the exception registered at this place in the module tree

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 We only use it here so far. Seems at-least as good as before ⏩

Can update in a follow-up PR if you have a suggestion

@MadLittleMods MadLittleMods changed the title Split out deferred and tokio_runtime to their own Rust crates Split out deferred and tokio_runtime to their own Rust modules Jun 19, 2026
@MadLittleMods MadLittleMods merged commit 42138ad into develop Jun 20, 2026
79 of 81 checks passed
@MadLittleMods MadLittleMods deleted the madlittlemods/deferred-and-tokio-runtime-crates branch June 20, 2026 03:21
@MadLittleMods

Copy link
Copy Markdown
Contributor Author

Thanks for the review @erikjohnston and @sandhose 🐜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants