How to use the aiomas.subproc.Manager function in aiomas

To help you get started, we’ve selected a few aiomas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frnsys / system_designer / syd / node / node.py View on Github external
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')

aiomas

Asyncio-based, layered networking library providing request-reply channels, RPC, and multi-agent systems.

MIT
Latest version published 6 years ago

Package Health Score

42 / 100
Full package analysis