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

Commit ef52738

Browse files
author
Sean Quah
committed
Don't cancel Deferreds that readers or writers are waiting on
1 parent 10cdb53 commit ef52738

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

synapse/util/async_helpers.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,10 @@ async def _ctx_manager() -> AsyncIterator[None]:
513513
try:
514514
# Wait for the latest writer to finish.
515515
# May raise a `CancelledError` if the `Deferred` wrapping us is
516-
# cancelled.
516+
# cancelled. The `Deferred` we are waiting on must not be cancelled,
517+
# since we do not own it.
517518
if curr_writer:
518-
await make_deferred_yieldable(curr_writer)
519+
await make_deferred_yieldable(stop_cancellation(curr_writer))
519520
yield
520521
finally:
521522
with PreserveLoggingContext():
@@ -546,8 +547,9 @@ async def _ctx_manager() -> AsyncIterator[None]:
546547
try:
547548
# Wait for all current readers and the latest writer to finish.
548549
# May raise a `CancelledError` if the `Deferred` wrapping us is
549-
# cancelled.
550-
await make_deferred_yieldable(to_wait_on_defer)
550+
# cancelled. The `Deferred`s we are waiting on must not be cancelled,
551+
# since we do not own them.
552+
await make_deferred_yieldable(stop_cancellation(to_wait_on_defer))
551553
yield
552554
finally:
553555

0 commit comments

Comments
 (0)