def __init__(self,
                 addr: str,
                 loop: Optional[asyncio.AbstractEventLoop]=None,
                 debug: bool=False,
                 compreser: Optional[str]=None,
                 heart_beat: Optional[int]=None):
        """初始化RPC客户端.

        Parameters:
            addr (str): - 形如`tcp://xxx:xxx@xxx:xxx`的字符串
            loop (Optional[asyncio.AbstractEventLoop]): - 事件循环
            debug (bool): - 是否使用debug模式,默认为否
            compreser(Optional[str]): - 是否使用压缩工具压缩传输信息,以及压缩工具是什么,默认为不使用.
            heart_beat (Optional[int]):- 是否使用心跳机制确保连接不会因过期而断开,默认为不使用.

        """
        pas = urlparse(addr)
        if pas.scheme != "tcp":
            raise abort(505, "unsupported scheme for this protocol")
        # public
        self.username = pas.username
        self.password = pas.password
        self.hostname = pas.hostname
        self.port = pas.port
        self.loop = loop or asyncio.get_event_loop()
        self.debug = debug
        if compreser is not None:
            _compreser = self.COMPRESERS.get(compreser)
            if _compreser is not None:
                self.compreser = _compreser
            else:
                raise RuntimeError("compreser unsupport")
        else:
            self.compreser = None
        self.heart_beat = heart_beat

        self.closed = True
        self.reader = None
        self.writer = None
        self.tasks = {}
        self.remote_info = None
        # protected
        self._gens_queue = {}
        self._login_fut = None
        self._response_task = None
        self._heartbeat_task = None
        if self.debug is True:
            self.loop.set_debug(True)
def __init__ ( self , addr : str , loop : Optional [ asyncio . AbstractEventLoop ] = None , debug : bool = False , compreser : Optional [ str ] = None , heart_beat : Optional [ int ] = None ) : pas = urlparse ( addr ) if pas . scheme != "tcp" : raise abort ( 505 , "unsupported scheme for this protocol" ) self . username = pas . username self . password = pas . password self . hostname = pas . hostname self . port = pas . port self . loop = loop or asyncio . get_event_loop ( ) self . debug = debug if compreser is not None : _compreser = self . COMPRESERS . get ( compreser ) if _compreser is not None : self . compreser = _compreser else : raise RuntimeError ( "compreser unsupport" ) else : self . compreser = None self . heart_beat = heart_beat self . closed = True self . reader = None self . writer = None self . tasks = { } self . remote_info = None self . _gens_queue = { } self . _login_fut = None self . _response_task = None self . _heartbeat_task = None if self . debug is True : self . loop . set_debug ( True )
初始化RPC客户端.

        Parameters:
            addr (str): - 形如`tcp://xxx:xxx@xxx:xxx`的字符串
            loop (Optional[asyncio.AbstractEventLoop]): - 事件循环
            debug (bool): - 是否使用debug模式,默认为否
            compreser(Optional[str]): - 是否使用压缩工具压缩传输信息,以及压缩工具是什么,默认为不使用.
            heart_beat (Optional[int]):- 是否使用心跳机制确保连接不会因过期而断开,默认为不使用.