Package: aiomas
aiomas – A library for multi-agent systems and RPC based on asyncioaiomasis an easy-to-use library forrequest-reply channels,remote
procedure calls (RPC)andmulti-agent systems (MAS).  It’s written in pure
Python on top ofasyncio.Here are three simple examples that show the different layers of aiomas and
what they add on top of each other:Therequest-reply channelhas the lowest level of abstraction (but already
offers more then vanilla asyncio):>>>importaiomas>>>>>>>>>asyncdefhandle_client(channel):..."""Handle a client connection."""...req=awaitchannel.recv()...print(req.content)...awaitreq.reply('cya')...awaitchannel.close()>>>>>>>>>asyncdefclient():..."""Client coroutine: Send a greeting to the server and wait for a
...     reply."""...channel=awaitaiomas.channel.open_connection(('localhost',5555))...rep=awaitchannel.send('ohai')...print(rep)...awaitchannel.close()>>>>>>>>>server=aiomas.run(aiomas.channel.start_server(('localhost',5555),handle_client))>>>aiomas.run(client())ohaicya>>>server.close()>>>aiomas.run(server.wait_closed())TheRPC layeradds remote procedure calls on top of it:>>>importaiomas>>>>>>>>>classMathServer:...router=aiomas.rpc.Service()......@router.expose...defadd(self,a,b):...returna+b...>>>>>>asyncdefclient():..."""Client coroutine: Call the server's "add()" method."""...rpc_con=awaitaiomas.rpc.open_connection(('localhost',5555))...rep=awaitrpc_con.remote.add(3,4)...print('What’s 3 + 4?',rep)...awaitrpc_con.close()>>>>>>server=aiomas.run(aiomas.rpc.start_server(('localhost',5555),MathServer()))>>>aiomas.run(client())What’s3+4?7>>>server.close()>>>aiomas.run(server.wait_closed())Finally, theagent layerhides some of the boilerplate code required to setup
the sockets and allows agent instances to easily talk with each other:>>>importaiomas>>>>>>classTestAgent(aiomas.Agent):...def__init__(self,container):...super().__init__(container)...print('Ohai, I am%s'%self)......asyncdefrun(self,addr):...remote_agent=awaitself.container.connect(addr)...ret=awaitremote_agent.service(42)...print('%sgot%sfrom%s'%(self,ret,remote_agent))......@aiomas.expose...defservice(self,value):...returnvalue>>>>>>c=aiomas.Container.create(('localhost',5555))>>>agents=[TestAgent(c)foriinrange(2)]Ohai,IamTestAgent('tcp://localhost:5555/0')Ohai,IamTestAgent('tcp://localhost:5555/1')>>>aiomas.run(until=agents[0].run(agents[1].addr))TestAgent('tcp://localhost:5555/0')got42fromTestAgentProxy('tcp://localhost:5555/1')>>>c.shutdown()aiomasis released under the MIT license. It requires Python 3.4 and above
and runs on Linux, OS X, and Windows.Installationaiomasrequires Python >= 3.6 (or PyPy3 >= 5.10.0).  It uses theJSONcodec
by default and only has pure Python dependencies.Installaiomasviapipby running:$pipinstallaiomasYou can enable the optionalMsgPackcodec or itsBlosccompressed version
by installing the corresponding features (note, that you need a C compiler to
install them):$pipinstallaiomas[mp]# Enables the MsgPack codec$pipinstallaiomas[mpb]# Enables the MsgPack and MsgPackBlosc codecsFeaturesaiomasjust puts three layers of abstraction around raw TCP / unix domain
sockets provided byasyncio:Agents and agent containers:The top-layer provides a simple base class for your own agents. All agents
live in a container.Containers take care of creating agent instances and performing the
communication between them.The container provides aclockfor the agents. This clock can either be
synchronized with the real (wall-clock) time or be set by an external process
(e.g., other simulators).RPC:Therpclayer implements remote procedure calls which let you call methods
on remote objects nearly as if they were normal objects:Instead ofret = obj.meth(arg)you writeret = await obj.meth(arg).Request-reply channel:Thechannellayer is the basis for therpclayer. It sendsJSONorMsgPackencoded byte strings over TCP or unix domain sockets. It also maps
replies (of success or failure) to their corresponding request.Other features:TLS support for authorization and encrypted communication.Interchangeable and extensible codecs: JSON and MsgPack (the latter
optionally compressed with Blosc) are built-in.  You can add custom codecs or
write (de)serializers for your own objects to extend a codec.Deterministic, emulated sockets: ALocalQueuetransport lets you send and
receive message in a deterministic and reproducible order within a single
process.  This helps testing and debugging distributed algorithms.Planned featuresSome ideas for future releases:Optional automatic re-connect after connection lossContributeIssue Tracker:https://gitlab.com/sscherfke/aiomas/issuesSource Code:https://gitlab.com/sscherfke/aiomasSet-up a development environment with:$virtualenv-p`whichpython3`aiomas$pipinstall-rrequirements-setup.txtRun the tests with:$pytest$# or$toxSupportDocumentation:https://aiomas.readthedocs.io/en/latest/Mailing list:https://groups.google.com/forum/#!forum/python-tulipStack Overflow:http://stackoverflow.com/questions/tagged/aiomasIRC: #asyncioLicenseThe project is licensed under the MIT license.Changelog2.0.1 – 2017-12-29[CHANGE] Restore support for Python 3.5 so that the docs on Read the Docs
build again.2.0.0 – 2017-12-28[BREAKING] Converted to f-Strings andasync/awaitsyntax.  The
minimum required Python versions are now Python 3.6 and PyPy3 5.10.0.[BREAKING] Removedaiomas.util.async()andaiomas.util.create_task().[CHANGE] Move from Bitbucket and Mercurial to GitLab and Git.[FIX] Adjust to asyncio changes and explicitly pass references to the current
event loop where necessary.You can find information about older versions in thedocumentation.AuthorsThe original author of aiomas is Stefan Scherfke.The initial development has kindly been supported byOFFIS.