core.py 文件源码

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

项目:agentzero 作者: gabrielfalcao 项目源码 文件源码
def wait_until_ready(self, name, polling_mechanism, timeout=None, polling_timeout=None):
        """Briefly waits until the socket is ready to be used, yields to other
        greenlets until the socket becomes available.

        returns the socket if available within the given timeout, or ``None``

        :param socket_name: the socket name
        :param polling_mechanism: either ``zmq.POLLIN`` or ``zmq.POLLOUT``
        :param timeout: the timeout in seconds (accepts float) in which it
          should wait for the socket to become available
          (optional, defaults to ``core.DEFAULT_TIMEOUT_IN_SECONDS``)
        :param polling_timeout: the polling timeout in miliseconds that will
          be passed to ``zmq.Poller().poll()``.
          (optional, defaults to ``core.DEFAULT_POLLING_TIMEOUT``)
        """
        timeout = timeout is None and self.timeout or timeout
        polling_timeout = polling_timeout is None and self.polling_timeout or polling_timeout
        start = time.time()
        current = start
        while current - start < timeout:
            self.engage(polling_timeout)
            socket = self.ready(name, polling_mechanism, timeout=timeout)
            current = time.time()
            if socket:
                return socket
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号