本文整理汇总了Python中thriftpy.rpc.make_client函数的典型用法代码示例。如果您正苦于以下问题:Python make_client函数的具体用法?Python make_client怎么用?Python make_client使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_client函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_nimbus_client
def get_nimbus_client(env_config=None, host=None, port=None, timeout=7000):
"""Get a Thrift RPC client for Nimbus given project's config file.
:param env_config: The project's parsed config.
:type env_config: `dict`
:param host: The host to use for Nimbus. If specified, `env_config` will
not be consulted.
:type host: `str`
:param port: The port to use for Nimbus. If specified, `env_config` will
not be consulted.
:type port: `int`
:param timeout: The time to wait (in milliseconds) for a response from
Nimbus.
:param timeout: `int`
:returns: a ThriftPy RPC client to use to communicate with Nimbus
"""
if host is None:
host, port = get_nimbus_host_port(env_config)
nimbus_client = make_client(
Nimbus,
host=host,
port=port,
proto_factory=TBinaryProtocolFactory(),
trans_factory=TFramedTransportFactory(),
timeout=timeout,
)
return nimbus_client
示例2: client
def client(self):
client = make_client(
publication_stats_thrift.PublicationStats,
self._address,
self._port
)
return client
示例3: re_init
def re_init():
try:
global client
client = make_client(broker_thrift.TradeService, config.BROKER_HOST, config.BROKER_PORT,
proto_factory=TBinaryProtocolFactory(),
trans_factory=TFramedTransportFactory(),
timeout=60000)
except Exception as e:
logging.warn("make_client exception")
traceback.print_exc()
示例4: main
def main():
host = '127.0.0.1' if len(sys.argv) < 2 else sys.argv[1]
port = 9090 if len(sys.argv) < 3 else int(sys.argv[2])
uniqueid_thrift = thriftpy.load('../protocol/uniqueid.thrift', module_name='uniqueid_thrift')
client = make_client(uniqueid_thrift.Uniqueid, host, port)
request = uniqueid_thrift.UniqueidRequest()
request.logid = random.randint(-2147483648, 2147483647)
request.serial = random.randint(0, 9)
request.length = random.randint(1, 10)
response = client.uniqueid(request)
print(response)
示例5: write_multiple
def write_multiple(self, spans):
entries = [self.__span_to_entry(span) for span in spans]
# TODO(will): The old implementation used to open and close transport here, with the new
# client based API this seems like the only way to get parity. Not sure if we would rather
# try persistent connections + reconnecting in the long run.
client = make_client(scribe_thrift.scribe,
host=self.host,
port=self.port,
timeout=self.timeout,
proto_factory=self.protocol_factory,
trans_factory=self.transport_factory)
client.Log(entries)
client.close()
示例6: __init__
def __init__(self):
# We need to run a FrontendService server, even though it does nothing in
# practice
fes = make_server(sparrow_service_thrift.FrontendService,
FLAGS.sparrow_frontend_host, FLAGS.sparrow_frontend_port,
trans_factory=tf)
self.scheduler_client = make_client(sparrow_service_thrift.SchedulerService,
FLAGS.sparrow_scheduler_host,
FLAGS.sparrow_scheduler_port,
trans_factory=tf)
self.scheduler_client.registerFrontend("clusterMixApp",
FLAGS.sparrow_frontend_host + ":" +
str(FLAGS.sparrow_frontend_port))
示例7: handleClient
def handleClient(num, actual):
# Open independent client connection
client = make_client(service=echo_thrift.Echo, host='127.0.0.1',
port=9999, trans_factory=TFramedTransportFactory())
# UUID
uid = str(uuid4())
for i in range(num):
# Make thrift call and increment atomic count
txt = uid + str(i)
ret = client.echo(echo_thrift.Message(text=txt))
if (txt == ret):
with actual.get_lock():
actual.value += 1
示例8: start_client
def start_client():
while True:
while True:
try:
client = make_client(thrift_service.Ping, 'localhost', 9000)
break
except:
continue
while True:
try:
pong = client.ping()
except:
break
print(pong)
time.sleep(1)
continue
示例9: getClient
def getClient():
wwfAPIpathname = os.path.join('thrift', 'wwf_api.thrift')
wwfAPI_thrift = thriftpy.load(path=wwfAPIpathname, module_name='wwfAPI_thrift', include_dirs=['thrift'])
tTransport = TFramedTransportFactory()
client = make_client(wwfAPI_thrift.WwfApi, port=9090, trans_factory=tTransport)
return client
示例10: make_client
#!/usr/bin/env python
# coding: utf-8
import os
import thriftpy
from thriftpy.rpc import make_client
# Examples using thrift
if __name__ == '__main__':
citedby_thrift = thriftpy.load(os.path.join(os.path.dirname(
os.path.abspath(__file__)), 'citedby.thrift'))
client = make_client(citedby_thrift.Citedby, 'localhost', 11610)
print client.citedby_pid('S1516-89132010000300001', False)
print client.citedby_doi('10.1590/S1516-89132010000300001')
print client.citedby_meta(title='Biochemical and morphological changes during the growth kinetics of Araucaria angustifolia suspension cultures')
示例11: rpc_call
def rpc_call(call, server, *args):
client = make_client(lang_thrift.CodeExecutor, *server)
return getattr(client, call)(*args)
示例12: mk_client
def mk_client(self):
return make_client(addressbook.AddressBookService,
'127.0.0.1', self.port,
proto_factory=self.PROTOCOL_FACTORY,
trans_factory=self.TRANSPORT_FACTORY)
示例13: make_client
import thriftpy
pingpong_thrift = thriftpy.load("pingpong.thrift", module_name="pingpong_thrift")
from thriftpy.rpc import make_client
client = make_client(pingpong_thrift.PingPong, '127.0.0.1', 6000)
client.ping()
示例14: send_to_taskqueue
def send_to_taskqueue(task, task_id, ip, port):
client = make_client(enqueue_thrift.RPC, ip, port)
client.task_service(task, task_id)
示例15: make_client
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import thriftpy
from thriftpy.rpc import make_client
pingpong_thrift = thriftpy.load("pingpong.thrift", module_name="pingpong_thrift")
client = make_client(pingpong_thrift.PingPong, '0.0.0.0', 6000)
print client.ping()