def create_client(
    client_klass,
    *,
    host=None,
    port=None,
    loop=None,
    timeouts=None,
    client_type=None
):
    """
    create a asyncio thrift client and return a context manager for it
    This is a coroutine
    :param client_klass: thrift Client class
    :param host: hostname/ip, None = loopback
    :param port: port number
    :param loop: asyncio event loop
    :returns: a Context manager which provides the thrift client
    """
    if not loop:
        loop = asyncio.get_event_loop()
    transport, protocol = yield from loop.create_connection(
        ThriftClientProtocolFactory(
            client_klass,
            loop=loop,
            timeouts=timeouts,
            client_type=client_type,
        ),
        host=host,
        port=port,
    )
    return protocol_manager(protocol)
Beispiel #2
0
def create_client(client_klass,
                  host=None,
                  port=None,
                  loop=None,
                  timeouts=None,
                  client_type=None):
    """
    create a Trollius thrift client and return a context manager for it
    This is a coroutine
    :param client_klass: thrift Client class
    :param host: hostname/ip, None = loopback
    :param port: port number
    :param loop: Trollius event loop
    :returns: a Context manager which provides the thrift client
    """
    if not loop:
        loop = asyncio.get_event_loop()
    transport, protocol = yield From(
        loop.create_connection(
            ThriftClientProtocolFactory(
                client_klass,
                loop=loop,
                timeouts=timeouts,
                client_type=client_type,
            ),
            host=host,
            port=port,
        ))
    raise Return(protocol_manager(protocol))
Beispiel #3
0
def create_client(client_klass, host=None, port=None, loop=None):
    """
    create a Trollius thrift client and return a context manager for it
    This is a coroutine
    :param client_klass: thrift Client class
    :param host: hostname/ip, None = loopback
    :param port: port number
    :param loop: Trollius event loop
    :returns: a Context manager which provides the thrift client
    """
    if not loop:
        loop = asyncio.get_event_loop()
    transport, protocol = yield From(
        loop.create_connection(ThriftClientProtocolFactory(client_klass), host=host, port=port)
    )
    raise Return(protocol_manager(protocol))
Beispiel #4
0
def create_client(client_klass, *, host=None, port=None, loop=None):
    """
    create a asyncio thrift client and return a context manager for it
    This is a coroutine
    :param client_klass: thrift Client class
    :param host: hostname/ip, None = loopback
    :param port: port number
    :param loop: asyncio event loop
    :returns: a Context manager which provides the thrift client
    """
    if not loop:
        loop = asyncio.get_event_loop()
    transport, protocol = yield from loop.create_connection(
        TAsyncioServer.ThriftClientProtocolFactory(client_klass),
        host=host,
        port=port)
    return protocol_manager(protocol)
Beispiel #5
0
 async def as_protocol_manager():
     _, protocol = await self.coro
     return protocol_manager(protocol)
def async_protocol_manager(coro):
    _, protocol = yield From(coro)
    raise Return(protocol_manager(protocol))
Beispiel #7
0
 async def as_protocol_manager():
     _, protocol = await self.coro
     return protocol_manager(protocol)
Beispiel #8
0
def async_protocol_manager(coro):
    _, protocol = yield From(coro)
    raise Return(protocol_manager(protocol))