mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-24 10:35:46 +03:00
synapse/util/__init__.py:unwrap_deferred was unused
This commit is contained in:
parent
527d95dea0
commit
372ac60375
1 changed files with 0 additions and 28 deletions
|
@ -29,34 +29,6 @@ def unwrapFirstError(failure):
|
|||
return failure.value.subFailure
|
||||
|
||||
|
||||
def unwrap_deferred(d):
|
||||
"""Given a deferred that we know has completed, return its value or raise
|
||||
the failure as an exception
|
||||
"""
|
||||
if not d.called:
|
||||
raise RuntimeError("deferred has not finished")
|
||||
|
||||
res = []
|
||||
|
||||
def f(r):
|
||||
res.append(r)
|
||||
return r
|
||||
d.addCallback(f)
|
||||
|
||||
if res:
|
||||
return res[0]
|
||||
|
||||
def f(r):
|
||||
res.append(r)
|
||||
return r
|
||||
d.addErrback(f)
|
||||
|
||||
if res:
|
||||
res[0].raiseException()
|
||||
else:
|
||||
raise RuntimeError("deferred did not call callbacks")
|
||||
|
||||
|
||||
class Clock(object):
|
||||
"""A small utility that obtains current time-of-day so that time may be
|
||||
mocked during unit-tests.
|
||||
|
|
Loading…
Reference in a new issue