XML-RPC client for asyncio
Project description
Asyncio version of the standard lib xmlrpc
aioxmlrpc.client, which works like xmlrpc.client but uses coroutines, has been implemented.
aioxmlrpc.client is based on httpx for the transport, and just patch the necessary from the python standard library to get it working.
aioxmlrpc.server, which works much like xmlrpc.server, but runs on the asyncio event loop and handles remote procedure calls (RPC) using both regular functions and coroutines.
aioxmlrpc.server is based on starlette and uvicorn for handling HTTP.
Installation
aioxmlrpc is available on PyPI, it can simply be installed with your favorite tool, example with pip here.
pip install aioxmlrpc
The server dependencies is installed using the extra syntax.
pip install "aioxmlrpc[server]"
Getting Started
Client
This example show how to print the current version of the Gandi XML-RPC api.
import asyncio
from aioxmlrpc.client import ServerProxy
async def print_gandi_api_version():
api = ServerProxy('https://rpc.gandi.net/xmlrpc/')
result = await api.version.info()
print(result)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(print_gandi_api_version())
loop.stop()
Run the example
uv run examples/gandi_api_version.py
Server
This example show an exemple of the server side.
import asyncio
from aioxmlrpc.server import SimpleXMLRPCServer
class Api:
def info(self):
return "1.0.0"
async def sleep(self):
await asyncio.sleep(1)
return "done"
async def main():
server = SimpleXMLRPCServer(("0.0.0.0", 8080))
server.register_instance(Api(), allow_dotted_names=True)
await server.serve_forever()
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aioxmlrpc-0.10.0.tar.gz.
File metadata
- Download URL: aioxmlrpc-0.10.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.24.0 CPython/3.12.10 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b948cd8e256240ed3f1bc1288f79a90d30c754e915962d0d6d6a17e93337452b
|
|
| MD5 |
585e4402c0154e593f0ae6f303fb7f68
|
|
| BLAKE2b-256 |
26c41c823de8353cd67f59470d46b606b447d22f69be135432afd91a9bf6bc0b
|
File details
Details for the file aioxmlrpc-0.10.0-py3-none-any.whl.
File metadata
- Download URL: aioxmlrpc-0.10.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.24.0 CPython/3.12.10 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
334ea045e4475bf30a768e77ef299e104f7fac42dd7e28d995dc714e7d94b82e
|
|
| MD5 |
3994612c92c90f1bb8a313689ebc2eb3
|
|
| BLAKE2b-256 |
053b7b25e15be0e6a4855ecfad93f5c959606d1df2f6c4c247fb8ff7afe0bf2c
|