Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Convert the typing handler to async/await. #7679

Merged
merged 3 commits into from
Jun 17, 2020
Merged

Conversation

clokep
Copy link
Member

@clokep clokep commented Jun 11, 2020

There's a couple of odd methods in here, in particular:

  • _stopped_typing was yielded, but wasn't a Deferred.
  • get_new_events doesn't need to be a coroutine, but I think it expects to be one based on the callers.
  • get_success need to be used in tests instead of getSuccessOf for old deps, I think.

@clokep clokep requested a review from a team June 16, 2020 18:03
@@ -163,7 +164,7 @@ def test_started_typing_local(self):

self.assertEquals(self.event_source.get_current_key(), 0)

self.successResultOf(
self.get_success(
Copy link
Member

Choose a reason for hiding this comment

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

these aren't quite the same thing. successResultOf asserts that the thing has already completed; get_success does not do that. I think tests.test_utils.get_awaitable_result should do what you want here.

That said, it probably doesn't matter here.

Copy link
Member Author

Choose a reason for hiding this comment

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

get_success seems to just handle if it is an awaitable, wrap it in a ensureDeferred and then call successResultOf:

synapse/tests/unittest.py

Lines 443 to 449 in 0361932

def get_success(self, d, by=0.0):
if inspect.isawaitable(d):
d = ensureDeferred(d)
if not isinstance(d, Deferred):
return d
self.pump(by=by)
return self.successResultOf(d)

So I think it does the same thing?

Copy link
Member

Choose a reason for hiding this comment

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

The difference is the self.pump.

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

lgtm!

@clokep clokep merged commit 3630825 into develop Jun 17, 2020
@clokep clokep deleted the clokep/async-typing branch June 17, 2020 14:38
@clokep clokep mentioned this pull request Jul 30, 2020
48 tasks
babolivier pushed a commit that referenced this pull request Sep 1, 2021
* commit '363082561':
  Convert the typing handler to async/await. (#7679)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants