def setTimeout(self, seconds, timeoutFunc=timeout, *args, **kw):
"""Set a timeout function to be triggered if I am not called.
@param seconds: How long to wait (from now) before firing the
timeoutFunc.
@param timeoutFunc: will receive the Deferred and *args, **kw as its
arguments. The default timeoutFunc will call the errback with a
L{TimeoutError}.
"""
warnings.warn(
"Deferred.setTimeout is deprecated. Look for timeout "
"support specific to the API you are using instead.",
DeprecationWarning, stacklevel=2)
if self.called:
return
assert not self.timeoutCall, "Don't call setTimeout twice on the same Deferred."
from twisted.internet import reactor
self.timeoutCall = reactor.callLater(
seconds,
lambda: self.called or timeoutFunc(self, *args, **kw))
return self.timeoutCall
评论列表
文章目录