callback.py 文件源码

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

项目:sublimeTextConfig 作者: luoye-fe 项目源码 文件源码
def initialize_timeout(self) -> None:
        """Initialize the timeouts if any
        """

        def _timeout_callback(*args: Any, **kwargs: Any) -> None:
            """Defualt timeout callback dummy method, can be overriden
            """
            raise RuntimeError('Timeout occurred on {}'.format(self.hexid))

        def _on_timeout(func: Callable, *args: Any, **kwargs: Any) -> None:
            """We need this wrapper to don't call timeout by accident
            """
            if self._status is CallbackStatus.unfired:
                self.status = CallbackStatus.timed_out
                func(*args, **kwargs)

        if self.timeout > 0:
            self.waiting_for_timeout = True
            callback = self.callbacks.get('timed_out', _timeout_callback)
            sublime.set_timeout(
                partial(_on_timeout, callback), self.timeout * 1000
            )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号