美文网首页
rpyc遇到的坑

rpyc遇到的坑

作者: 你猜_19ca | 来源:发表于2019-03-29 17:58 被阅读0次

执行单个任务,超过30s自动中断

....
  raise AsyncResultTimeout("result expired")
TimeoutError: result expired

首先看了下官方文档 https://rpyc.readthedocs.io/en/latest/tutorial/tut5.html

set_expiry(seconds) - sets the expiry time of the AsyncResult. By default, no expiry time is set

上面是说可以通过设置设置到期时间来修改。没找到怎么通过client获取AsyncResult对象的入口。无奈去分析了一下rypc源码:

  • 先找到报错位置:
def wait(self):
        """Waits for the result to arrive. If the AsyncResult object has an
        expiry set, and the result did not arrive within that timeout,
        an :class:`AsyncResultTimeout` exception is raised"""
        while not self._is_ready and not self._ttl.expired():
            self._conn.serve(self._ttl)
        if not self._is_ready:
            raise AsyncResultTimeout("result expired")
  • 然后发现调了self._ttl.expired(), 找到set_expiry位置
def set_expiry(self, timeout):
        """Sets the expiry time (in seconds, relative to now) or ``None`` for
        unlimited time

        :param timeout: the expiry time in seconds or ``None``
        """
        self._ttl = Timeout(timeout)
  • 全局搜索timeout, 终于被我发现了在protocol.py文件里
def sync_request(self, handler, *args):
        """Sends a synchronous request (waits for the reply to arrive)

        :raises: any exception that the requets may be generated
        :returns: the result of the request
        """
        timeout = self._config["sync_request_timeout"]
        return self.async_request(handler, *args, timeout=timeout).value
DEFAULT_CONFIG = dict(
   ...
    sync_request_timeout = 30,
)

原因是AsyncResult对象的默认超时是30s
解决方案
客户端连接的时候在config里添加超时时间

client = rpyc.connect("xxx.xxx.xxx", 11111, config={'sync_request_timeout': 120})

相关文章

  • rpyc遇到的坑

    执行单个任务,超过30s自动中断 首先看了下官方文档 https://rpyc.readthedocs.io/en...

  • 遇到的坑

    1.文字两端居中 2.多个异步请求的执行顺序 点击页面上一个按钮发送两个ajax请求时,这两个异步请求会同时发送,...

  • 遇到的坑

    1、 2、每次改完pom.xml后项目的 Language level都会变成7,使用了jdk8新功能的地方都会报...

  • 遇到的坑++

    1.加在一个view的时候报了一个异常 android.view.InflateException: Binary...

  • 遇到的坑

    键盘通知导致UI异常现象描述:本地详情页的inputView输入框,做了很多的功能,由多个view组成,这时点击微...

  • 遇到的坑

    第一次访问是 this page could not be found,刷新一下就好了 路径错误 多了一个 ‘/’

  • iOS开发中遇到过的坑

    iOS开发中遇到过的坑 iOS开发中遇到过的坑

  • display属性

    遇到的坑

  • IQKeyBoardManager 滑动删除text内容

    IQKeyBoardManager遇到的坑

  • Jenkins遇到的坑

    1、 自定义Shell 中使用sudo报错 - sudo:抱歉,您必须拥有一个终端来执行 sudo + '[' '...

网友评论

      本文标题:rpyc遇到的坑

      本文链接:https://www.haomeiwen.com/subject/nodrbqtx.html