Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if base_url == self._base_url[:-1]:
results.extend(self.bulk_get_local(ids, var))
else:
manager_url = '{}/0'.format(base_url)
tasks.append(self.bulk_get_remote(manager_url, ids, var))
# clean this up
return results + list(itertools.chain.from_iterable(await asyncio.gather(*tasks)))
def bulk_get_local(self, ids, var):
return [self.agents.dict[id].get(var) for id in ids]
async def bulk_get_remote(self, manager_url, ids, var):
manager = await self.connect(manager_url)
return await manager.bulk_get(ids, var)
class NodeManager(aiomas.subproc.Manager):
"""a special agent that manages a node"""
@aiomas.expose
def states(self):
"""iterator over every agent state in the node"""
return self.container.states()
@aiomas.expose
def update_agents(self, *args, **kwargs):
"""call the 'update' method on all agents"""
self.container.update_agents(*args, **kwargs)
@aiomas.expose
async def decide_agents(self, *args, **kwargs):
"""call the 'decide' method on all agents"""
self.container.logger.debug('manager DECIDING AGENTS')