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

Convert the typing handler to async/await. - #7679

Merged
clokep merged 3 commits into
developfrom
clokep/async-typing
Jun 17, 2020
Merged

clokep merged 3 commits into
developfrom
clokep/async-typing

Conversation

@clokep

@clokep clokep commented Jun 11, 2020 •

Copy link
Copy Markdown
Member

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 force-pushed the clokep/async-typing branch from ada08e3 to 600d412 Compare June 16, 2020 15:03
@clokep
clokep requested a review from a team June 16, 2020 18:03
self.assertEquals(self.event_source.get_current_key(), 0)

self.successResultOf(
self.get_success(

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.

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
Copy Markdown
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
Copy Markdown
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.

@richvdh richvdh left a comment

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.

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
19 of 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