Replace custom DeferredTimeoutError with defer.TimeoutError
This commit is contained in:
parent
6c48aa0256
commit
9407bcf37a
|
@ -26,7 +26,6 @@ from synapse.handlers.presence import format_user_presence_state
|
||||||
from synapse.metrics import LaterGauge
|
from synapse.metrics import LaterGauge
|
||||||
from synapse.types import StreamToken
|
from synapse.types import StreamToken
|
||||||
from synapse.util.async_helpers import (
|
from synapse.util.async_helpers import (
|
||||||
DeferredTimeoutError,
|
|
||||||
ObservableDeferred,
|
ObservableDeferred,
|
||||||
timeout_deferred,
|
timeout_deferred,
|
||||||
)
|
)
|
||||||
|
@ -354,7 +353,7 @@ class Notifier(object):
|
||||||
# Update the prev_token to the current_token since nothing
|
# Update the prev_token to the current_token since nothing
|
||||||
# has happened between the old prev_token and the current_token
|
# has happened between the old prev_token and the current_token
|
||||||
prev_token = current_token
|
prev_token = current_token
|
||||||
except DeferredTimeoutError:
|
except defer.TimeoutError:
|
||||||
break
|
break
|
||||||
except defer.CancelledError:
|
except defer.CancelledError:
|
||||||
break
|
break
|
||||||
|
@ -568,7 +567,7 @@ class Notifier(object):
|
||||||
try:
|
try:
|
||||||
with PreserveLoggingContext():
|
with PreserveLoggingContext():
|
||||||
yield listener.deferred
|
yield listener.deferred
|
||||||
except DeferredTimeoutError:
|
except defer.TimeoutError:
|
||||||
break
|
break
|
||||||
except defer.CancelledError:
|
except defer.CancelledError:
|
||||||
break
|
break
|
||||||
|
|
|
@ -374,16 +374,10 @@ class ReadWriteLock(object):
|
||||||
defer.returnValue(_ctx_manager())
|
defer.returnValue(_ctx_manager())
|
||||||
|
|
||||||
|
|
||||||
class DeferredTimeoutError(Exception):
|
|
||||||
"""
|
|
||||||
This error is raised by default when a L{Deferred} times out.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def _cancelled_to_timed_out_error(value, timeout):
|
def _cancelled_to_timed_out_error(value, timeout):
|
||||||
if isinstance(value, failure.Failure):
|
if isinstance(value, failure.Failure):
|
||||||
value.trap(CancelledError)
|
value.trap(CancelledError)
|
||||||
raise DeferredTimeoutError(timeout, "Deferred")
|
raise defer.TimeoutError(timeout, "Deferred")
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
@ -408,7 +402,7 @@ def timeout_deferred(deferred, timeout, reactor, on_timeout_cancel=None):
|
||||||
the timeout.
|
the timeout.
|
||||||
|
|
||||||
The default callable (if none is provided) will translate a
|
The default callable (if none is provided) will translate a
|
||||||
CancelledError Failure into a DeferredTimeoutError.
|
CancelledError Failure into a defer.TimeoutError.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Deferred
|
Deferred
|
||||||
|
@ -427,7 +421,7 @@ def timeout_deferred(deferred, timeout, reactor, on_timeout_cancel=None):
|
||||||
logger.exception("Canceller failed during timeout")
|
logger.exception("Canceller failed during timeout")
|
||||||
|
|
||||||
if not new_d.called:
|
if not new_d.called:
|
||||||
new_d.errback(DeferredTimeoutError(timeout, "Deferred"))
|
new_d.errback(defer.TimeoutError(timeout, "Deferred"))
|
||||||
|
|
||||||
delayed_call = reactor.callLater(timeout, time_it_out)
|
delayed_call = reactor.callLater(timeout, time_it_out)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue