twisted.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:maas 作者: maas 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号