components.py 文件源码

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

项目:ribosome 作者: tek 项目源码 文件源码
def async_call(self, f: Callable[..., Any], *a: Any, **kw: Any) -> Any:
        ''' run a callback function on the main thread and return its
        value (blocking). the callback receives 'self' as an argument.
        '''
        if not shutdown:
            msg = 'running {} on main thread blocking'
            self.log.debug2(lambda: msg.format(format_funcall(f.__name__, a, kw)))
            result_fut = futures.Future()  # type: futures.Future
            @functools.wraps(f)
            def cb() -> None:
                result_fut.set_result(f(self, *a, **kw))
            self._run_on_main_thread(cb)
            result = result_fut.result()
            self.log.debug2(lambda: f'async returns {result}')
            return result
        else:
            return f(self, *a, **kw)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号