Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix `make_deferred_yieldable` to work with coroutines #6505

Merged
merged 3 commits into from Dec 10, 2019

Conversation

@erikjohnston
Copy link
Member

erikjohnston commented Dec 10, 2019

No description provided.

@erikjohnston erikjohnston requested a review from matrix-org/synapse-core Dec 10, 2019
Copy link
Member

richvdh left a comment

lgtm other than nitpicking over comments.

@@ -624,6 +626,11 @@ def make_deferred_yieldable(deferred):
(This is more-or-less the opposite operation to run_in_background.)
"""
if inspect.isawaitable(deferred):
# If we're given a coroutine we need to convert it to a deferred so that
# we can attach callbacks (and not immediately return).

This comment has been minimized.

Copy link
@richvdh

richvdh Dec 10, 2019

Member

I'm not convinced that's the reason we need to convert it to a deferred (we can do similar things by awaiting awaitables).

What it does do is to start running the coroutine and find out if it has finished or not, which saves us clearing and immediately restoring the logcontext in the common case that the coroutine completes synchronously.

This comment has been minimized.

Copy link
@erikjohnston

erikjohnston Dec 10, 2019

Author Member

Hmm, fair. I guess I was thinking of this in terms of converting to a future/deferred so that we could put the callbacks on it (since you can't do that on raw coroutines). Will reword

@erikjohnston erikjohnston merged commit 35f3c36 into develop Dec 10, 2019
22 checks passed
22 checks passed
buildkite/synapse Build #6032 passed (21 minutes, 29 seconds)
Details
buildkite/synapse/check-sample-config Passed (1 minute, 34 seconds)
Details
buildkite/synapse/check-style Passed (2 minutes, 10 seconds)
Details
buildkite/synapse/isort Passed (17 seconds)
Details
buildkite/synapse/mypy Passed (24 seconds)
Details
buildkite/synapse/newspaper-newsfile Passed (15 seconds)
Details
buildkite/synapse/packaging Passed (18 seconds)
Details
buildkite/synapse/pipeline Passed (4 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-postgres-9-dot-5 Passed (19 minutes, 7 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite Passed (7 minutes, 50 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite-slash-old-deps Passed (9 minutes, 1 second)
Details
buildkite/synapse/python-3-dot-6-slash-sqlite Passed (7 minutes, 33 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-11 Passed (18 minutes, 36 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-9-dot-5 Passed (18 minutes, 52 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-sqlite Passed (6 minutes, 56 seconds)
Details
buildkite/synapse/synapse-port-db-slash-python-3-dot-5-slash-postgres-9-dot-5 Passed (1 minute, 43 seconds)
Details
buildkite/synapse/synapse-port-db-slash-python-3-dot-7-slash-postgres-11 Passed (1 minute, 34 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-monolith Passed (12 minutes, 12 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-workers Passed (14 minutes, 48 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-sqlite-slash-monolith Passed (11 minutes, 2 seconds)
Details
buildkite/synapse/sytest-python-3-dot-7-slash-postgres-11-slash-monolith Passed (11 minutes, 14 seconds)
Details
buildkite/synapse/sytest-python-3-dot-7-slash-postgres-11-slash-workers Passed (11 minutes, 31 seconds)
Details
@erikjohnston erikjohnston deleted the erikj/make_deferred_yiedable branch Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.