multiprocessing commlayer for nens/asyncio-rpc using aioprocessing's
AioQueue
.
Allows using asyncio-rpc for local interprocess communication with and between
processes spawned using Python's multiprocessing module. Internally, this uses
aioprocessing.AioQueue
, which spawns threads in order to make blocking
multiprocessing.Queue
calls fit for use with asyncio, so be aware of that.
pip install git+https://gitlab.com/smheidrich/asyncio-rpc-aiopqueue.git
See the decorator example (adapted from asyncio-rpc's own decorator example) in
examples/decorators_aiopqueue
. In contrast to asyncio-rpc's example, client
and server here are called from within the same script (client.py
).
Usage is fairly analogous to that of the Redis commlayer, except:
- You create a pair of endpoints using
AiopQueueCommLayer.create_pair()
or, if you want to use your own queue, create them separately using the regular constructor. - You leave out all the serialization stuff because this is done via ordinary pickling.
- In contrast to "proper" RPC, in this use case you'll probably want to provide an RPC method that makes the server shut down. This is a bit tricky to do in asyncio-rpc. See the aforementioned example for how to do this (method was adapted from asyncio-rpc's tests).
The online documentation including the API reference can be found here.