connection.py 文件源码

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

项目:aiothrift 作者: ryanwang520 项目源码 文件源码
def create_connection(service, address=('127.0.0.1', 6000), *,
                      protocol_cls=TBinaryProtocol, timeout=None, loop=None, **kw):
    """Create a thrift connection.
    This function is a :ref:`coroutine <coroutine>`.

    Open a connection to the thrift server by address argument.

    :param service: a thrift service object
    :param address: a (host, port) tuple
    :param protocol_cls: protocol type, default is :class:`TBinaryProtocol`
    :param timeout: if specified, would raise `asyncio.TimeoutError` if one rpc call is longer than `timeout`
    :param loop: :class:`Eventloop <asyncio.AbstractEventLoop>` instance, if not specified, default loop is used.
    :param kw: params relaied to asyncio.open_connection()
    :return: newly created :class:`ThriftConnection` instance.
    """
    host, port = address
    reader, writer = yield from asyncio.open_connection(
        host, port, loop=loop, **kw)
    iprotocol = protocol_cls(reader)
    oprotocol = protocol_cls(writer)

    return ThriftConnection(service, iprot=iprotocol, oprot=oprotocol,
                            address=address, loop=loop, timeout=timeout)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号