Skip to content

Update FakeChannel.await_result(...) to drive async Rust (Tokio runtime/thread pool)#19879

Draft
MadLittleMods wants to merge 9 commits into
developfrom
madlittlemods/try-fake-channel-await-result-rust-changes
Draft

Update FakeChannel.await_result(...) to drive async Rust (Tokio runtime/thread pool)#19879
MadLittleMods wants to merge 9 commits into
developfrom
madlittlemods/try-fake-channel-await-result-rust-changes

Conversation

@MadLittleMods

@MadLittleMods MadLittleMods commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Update FakeChannel.await_result(...) to drive async Rust (Tokio runtime/thread pool)

Split off from #19878 (needed to drive requests in tests that use async Rust)

Follow-up to #19871

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)

@MadLittleMods MadLittleMods changed the title Try FakeChannel.await_result(...) changes on their own Try FakeChannel.await_result(...) changes to drive async Rust on their own Jun 25, 2026
Comment on lines +569 to +571
# `notifier.wait_for_stream_token(from_token)` only checks every 500ms so we
# need to match that in order to make sure we hit the wake-up for sure.
channel.await_result(timeout_ms=500)

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.

Previously, this worked because await_result(...) would advance 0.1s past the specified timeout_ms and I guess that worked out to hit the 500ms notifier.wait_for_stream_token(from_token) check interval every time.

Now await_result(...) can timeout when we exactly hit the timeout_ms so we weren't hitting it.

I've updated the second wait to be 500ms to match notifier.wait_for_stream_token(from_token) so we know that we can always hit the interval regardless of the current Twisted clock time.

@MadLittleMods MadLittleMods changed the title Try FakeChannel.await_result(...) changes to drive async Rust on their own Update FakeChannel.await_result(...) and friends to drive async Rust (Tokio runtime/thread pool) Jun 25, 2026
Comment thread changelog.d/19879.misc
@@ -0,0 +1 @@
Update `HomeserverTestCase.get_success(...)` and friends to drive async Rust (Tokio runtime/thread pool).

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.

Same changelog as #19871 so they merge

Comment thread tests/server.py
Comment on lines +331 to 332
# TODO: Why?
self._reactor.run()

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.

Prior art. Something to figure out in a future PR. Just noting that I don't know. The reactor should already be running and we can potentially remove it in another PR.

Comment thread tests/server.py
@@ -301,15 +302,85 @@ def transport(self) -> "FakeChannel":
def await_result(self, timeout_ms: int = 1000) -> None:

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.

Similar structure to what we've done in #19871

@MadLittleMods MadLittleMods changed the title Update FakeChannel.await_result(...) and friends to drive async Rust (Tokio runtime/thread pool) Update FakeChannel.await_result(...) to drive async Rust (Tokio runtime/thread pool) Jun 25, 2026
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.

1 participant