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

Commit

Permalink
Don't cancel Deferreds that readers or writers are waiting on
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Quah committed Feb 28, 2022
1 parent 10cdb53 commit ef52738
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions synapse/util/async_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,10 @@ async def _ctx_manager() -> AsyncIterator[None]:
try:
# Wait for the latest writer to finish.
# May raise a `CancelledError` if the `Deferred` wrapping us is
# cancelled.
# cancelled. The `Deferred` we are waiting on must not be cancelled,
# since we do not own it.
if curr_writer:
await make_deferred_yieldable(curr_writer)
await make_deferred_yieldable(stop_cancellation(curr_writer))
yield
finally:
with PreserveLoggingContext():
Expand Down Expand Up @@ -546,8 +547,9 @@ async def _ctx_manager() -> AsyncIterator[None]:
try:
# Wait for all current readers and the latest writer to finish.
# May raise a `CancelledError` if the `Deferred` wrapping us is
# cancelled.
await make_deferred_yieldable(to_wait_on_defer)
# cancelled. The `Deferred`s we are waiting on must not be cancelled,
# since we do not own them.
await make_deferred_yieldable(stop_cancellation(to_wait_on_defer))
yield
finally:

Expand Down

0 comments on commit ef52738

Please sign in to comment.