def callOutToThread(thing, func, *args, **kwargs):
"""Call out to the given `func` in another thread, but return `thing`.
For example::
d = client.fetchSomethingReallyImportant()
d.addCallback(callOutToThread, watchTheKettleBoil))
d.addCallback(doSomethingWithReallyImportantThing)
Use this where you need a side-effect when a :py:class:`~Deferred` is
fired, but you don't want to clobber the result. Note that the result
being passed through is *not* passed to the function.
Note also that if the call-out raises an exception, this will be
propagated; nothing is done to suppress the exception or preserve the
result in this case.
:return: :class:`Deferred`.
"""
return deferToThread(func, *args, **kwargs).addCallback(lambda _: thing)
评论列表
文章目录