def call_agent(self, data):
"""call a method on an agent and get the result"""
d = {'args': [], 'kwargs': {}}
d.update(data)
id = d['id']
# check locally
if id in self.agents:
agent = self.agents[id]
result = getattr(agent, d['func'])(*d['args'], **d['kwargs'])
if inspect.isgenerator(result):
result = yield from result
return result
# pass request to the arbiter
else:
d['cmd'] = 'call_agent'
return (yield from self.arbiter.send_recv(d))
评论列表
文章目录