本文整理汇总了Python中pyon.net.endpoint.RPCClient.request方法的典型用法代码示例。如果您正苦于以下问题:Python RPCClient.request方法的具体用法?Python RPCClient.request怎么用?Python RPCClient.request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.net.endpoint.RPCClient
的用法示例。
在下文中一共展示了RPCClient.request方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_dataset
# 需要导入模块: from pyon.net.endpoint import RPCClient [as 别名]
# 或者: from pyon.net.endpoint.RPCClient import request [as 别名]
def register_dataset(self, data_product_id=''):
procs,_ = self.clients.resource_registry.find_resources(restype=RT.Process, id_only=True)
pid = None
for p in procs:
if 'registration_worker' in p:
pid = p
if not pid:
log.warning('No registration worker found')
return
rpc_cli = RPCClient(to_name=pid)
rpc_cli.request({'data_product_id':data_product_id}, op='register_dap_dataset')
示例2: main
# 需要导入模块: from pyon.net.endpoint import RPCClient [as 别名]
# 或者: from pyon.net.endpoint.RPCClient import request [as 别名]
def main():
parser = argparse.ArgumentParser(description="CC Control script")
parser.add_argument("pidfile", help="pidfile to use. If not specified, uses the first one found.")
parser.add_argument("command", help="command to send to the container agent", choices=IContainerAgent.names())
parser.add_argument("commandargs", metavar="arg", nargs="*", help="arguments to the command being sent")
opts = parser.parse_args()
pidfile = opts.pidfile
if not pidfile:
raise Exception("No pidfile specified")
parms = {}
with open(pidfile, "r") as pf:
parms = msgpack.loads(pf.read())
assert parms, "No content in pidfile"
node, ioloop = make_node(parms["messaging"])
cc = RPCClient(node=node, name=(parms["container-xp"], parms["container-agent"]))
# make a manual call - this is to avoid having to have the IonObject for the call
methdefs = [x[1] for x in IContainerAgent.namesAndDescriptions() if x[0] == opts.command]
assert len(methdefs) == 1
arg_names = methdefs[0].positional # ('name', 'module', 'cls', 'config')
msg_args = msgpack.dumps(
dict(zip(arg_names, opts.commandargs))
) # ('name', <usrinp1>, 'cls', <usrinp2>) -> { 'name' : <usrinp1>, 'cls': <usrinp2> }
retval = cc.request(msg_args, op=opts.command)
print "Returned", retval
node.client.close()
示例3: register_dataset
# 需要导入模块: from pyon.net.endpoint import RPCClient [as 别名]
# 或者: from pyon.net.endpoint.RPCClient import request [as 别名]
def register_dataset(self, dataset_id='', external_data_product_name=''):
dataset_obj = self.read_dataset(dataset_id)
dataset_obj.registered = True
self.update_dataset(dataset=dataset_obj)
external_data_product_name = external_data_product_name or dataset_obj.name
procs,_ = self.clients.resource_registry.find_resources(restype=RT.Process, id_only=True)
pid = None
for p in procs:
if 'registration_worker' in p:
pid = p
if not pid:
log.warning('No registration worker found')
return
rpc_cli = RPCClient(to_name=pid)
rpc_cli.request({'dataset_id':dataset_id, 'data_product_name':external_data_product_name}, op='register_dap_dataset')
示例4: TestProcessInt
# 需要导入模块: from pyon.net.endpoint import RPCClient [as 别名]
# 或者: from pyon.net.endpoint.RPCClient import request [as 别名]
class TestProcessInt(IonIntegrationTestCase):
def setUp(self):
self._start_container()
self.pid = self.container.spawn_process('fake', 'pyon.ion.test.test_process', 'FakeService')
self.fsclient = RPCClient(to_name='fake_service')
@unittest.skip("timeouts removed 18 oct 2012")
def test_timeout_with_messaging(self):
with self.assertRaises(IonTimeout) as cm:
self.fsclient.request({}, op='takes_too_long', timeout=5)
self.assertIn('execute in allotted time', cm.exception.message)
@unittest.skipIf(os.getenv('CEI_LAUNCH_TEST', False), "Test reaches into container, doesn't work with CEI")
@unittest.skip("heartbeat failing process is disabled")
def test_heartbeat_failure(self):
self.patch_cfg('pyon.ion.process.CFG', {'cc':{'timeout':{'heartbeat_proc_count_threshold':2, 'heartbeat':1.0}}})
svc = self.container.proc_manager.procs[self.pid]
ip = svc._process
stopar = AsyncResult()
self.container.proc_manager.add_proc_state_changed_callback(lambda *args: stopar.set(args))
noticear = AsyncResult() # notify us when the call has been made
ar = ip._routing_call(svc.takes_too_long, None, noticear=noticear)
noticear.get(timeout=10) # wait for the call to be made
# heartbeat a few times so we trigger the failure soon
for x in xrange(2):
ip.heartbeat()
# wait for ip thread to kick over
ip._ctrl_thread.join(timeout=5)
# now wait for notice proc got canned
stopargs = stopar.get(timeout=5)
self.assertEquals(stopargs, (svc, ProcessStateEnum.FAILED, self.container))
# should've shut down, no longer in container's process list
self.assertEquals(len(self.container.proc_manager.procs), 0)
示例5: stats
# 需要导入模块: from pyon.net.endpoint import RPCClient [as 别名]
# 或者: from pyon.net.endpoint.RPCClient import request [as 别名]
def stats(cls,pid):
'''
RPC Method for querying a Transform's internal statistics
'''
rpc_cli = RPCClient(to_name=pid)
return rpc_cli.request({},op='_stat')