summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-09-15 11:38:39 +0100
committerErik Johnston <erik@matrix.org>2018-09-15 11:38:39 +0100
commit24efb2a70dfd8aa100507612836601991e11affc (patch)
tree82cfeb094e629a818d2c66ff35d3e5ba514ec5bc
parentMerge pull request #3875 from matrix-org/erikj/extra_timeouts (diff)
downloadsynapse-24efb2a70dfd8aa100507612836601991e11affc.tar.xz
Fix timeout function
Turns out deferred.cancel sometimes throws, so we do that last to ensure
that we always do resolve the new deferred.
-rw-r--r--synapse/util/async_helpers.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/synapse/util/async_helpers.py b/synapse/util/async_helpers.py
index 083e4f4128..40c2946129 100644
--- a/synapse/util/async_helpers.py
+++ b/synapse/util/async_helpers.py
@@ -456,11 +456,12 @@ def timeout_no_seriously(deferred, timeout, reactor):
 
     def time_it_out():
         timed_out[0] = True
-        deferred.cancel()
 
         if not new_d.called:
             new_d.errback(DeferredTimeoutError(timeout, "Deferred"))
 
+        deferred.cancel()
+
     delayed_call = reactor.callLater(timeout, time_it_out)
 
     def convert_cancelled(value):