Skip to main content

XML-RPC client for asyncio

Project description

https://github.com/mardiros/aioxmlrpc/actions/workflows/tests.yml/badge.svg https://codecov.io/gh/mardiros/aioxmlrpc/branch/master/graph/badge.svg?token=BR3KttC9uJ

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioxmlrpc-0.10.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aioxmlrpc-0.10.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

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

Hashes for aioxmlrpc-0.10.0.tar.gz
Algorithm Hash digest
SHA256 b948cd8e256240ed3f1bc1288f79a90d30c754e915962d0d6d6a17e93337452b
MD5 585e4402c0154e593f0ae6f303fb7f68
BLAKE2b-256 26c41c823de8353cd67f59470d46b606b447d22f69be135432afd91a9bf6bc0b

See more details on using hashes here.

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

Hashes for aioxmlrpc-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 334ea045e4475bf30a768e77ef299e104f7fac42dd7e28d995dc714e7d94b82e
MD5 3994612c92c90f1bb8a313689ebc2eb3
BLAKE2b-256 053b7b25e15be0e6a4855ecfad93f5c959606d1df2f6c4c247fb8ff7afe0bf2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page