client.py 文件源码

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

项目:treadmill 作者: Morgan-Stanley 项目源码 文件源码
def ws_loop(wsapi, message, snapshot, on_message, on_error=None,
            timeout=_DEFAULT_TIMEOUT):
    """Instance trace loop."""
    ws_conn = None
    since = 0

    while True:
        apis = context.GLOBAL.ws_api(wsapi)
        for api in apis:

            try:
                _LOGGER.debug('Connecting to %s, [timeout: %s]', api, timeout)
                ws_conn = ws_client.create_connection(api, timeout=timeout)
                _LOGGER.debug('Connected.')

                return _ws_events(ws_conn, message, snapshot, since,
                                  on_message, on_error)
            except ws_client.WebSocketTimeoutException as to_err:
                _LOGGER.debug('Connection timeout: %s, %s', api, str(to_err))
                continue
            except ws_client.WebSocketProxyException as proxy_err:
                _LOGGER.debug('Websocket connection error: %s, %s', api,
                              str(proxy_err))
                continue
            except socket.error:
                _LOGGER.debug('Connection failed: %s', api)
                continue
            except _RetryError as retry_err:
                since = retry_err.since

        if not ws_conn:
            raise WSConnectionError()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号