summary refs log tree commit diff
path: root/synapse/notifier.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-09-19 10:39:40 +0100
committerErik Johnston <erik@matrix.org>2018-09-19 10:39:40 +0100
commita334e1cacec5dd9c1a983415906d8ffea4a30134 (patch)
tree026fa629ce6212c0d093f6f9b148bdee135a4194 /synapse/notifier.py
parentupdate changelog for #3909 (diff)
downloadsynapse-a334e1cacec5dd9c1a983415906d8ffea4a30134.tar.xz
Update to use new timeout function everywhere.
The existing deferred timeout helper function (and the one into twisted)
suffer from a bug when a deferred's canceller throws an exception, #3842.

The new helper function doesn't suffer from this problem.
Diffstat (limited to 'synapse/notifier.py')
-rw-r--r--synapse/notifier.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/synapse/notifier.py b/synapse/notifier.py
index 82f391481c..2d683718fb 100644
--- a/synapse/notifier.py
+++ b/synapse/notifier.py
@@ -28,7 +28,7 @@ from synapse.types import StreamToken
 from synapse.util.async_helpers import (
     DeferredTimeoutError,
     ObservableDeferred,
-    add_timeout_to_deferred,
+    timeout_deferred,
 )
 from synapse.util.logcontext import PreserveLoggingContext, run_in_background
 from synapse.util.logutils import log_function
@@ -337,7 +337,7 @@ class Notifier(object):
                     # Now we wait for the _NotifierUserStream to be told there
                     # is a new token.
                     listener = user_stream.new_listener(prev_token)
-                    add_timeout_to_deferred(
+                    listener.deferred = timeout_deferred(
                         listener.deferred,
                         (end_time - now) / 1000.,
                         self.hs.get_reactor(),
@@ -559,11 +559,12 @@ class Notifier(object):
             if end_time <= now:
                 break
 
-            add_timeout_to_deferred(
-                listener.deferred.addTimeout,
-                (end_time - now) / 1000.,
-                self.hs.get_reactor(),
+            listener.deferred = timeout_deferred(
+                listener.deferred,
+                timeout=(end_time - now) / 1000.,
+                reactor=self.hs.get_reactor(),
             )
+
             try:
                 with PreserveLoggingContext():
                     yield listener.deferred