Git Product home page Git Product logo

aioxmlrpc's Introduction

aioxmlrpc

https://codecov.io/gh/mardiros/aioxmlrpc/branch/master/graph/badge.svg?token=BR3KttC9uJ

Asyncio version of the standard lib xmlrpc

Currently only aioxmlrpc.client, which works like xmlrpc.client but with coroutine is implemented.

Fill free to fork me if you want to implement the server part.

aioxmlrpc is based on httpx for the transport, and just patch the necessary from the python standard library to get it working.

Installation

aioxmlrpc is available on PyPI, it can simply be installed with your favorite tool, example with pip here.

pip install aioxmlrpc

Getting Started

This example show how to print the current version of the Gandi XML-RPC api.

import asyncio
from aioxmlrpc.client import ServerProxy


@asyncio.coroutine
def print_gandi_api_version():
    api = ServerProxy('https://rpc.gandi.net/xmlrpc/')
    result = yield from 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

poetry run examples/gandi_api_version.py

aioxmlrpc's People

Contributors

ajdavis avatar dependabot[bot] avatar ezeeyahoo avatar jettify avatar mardiros avatar mr-c avatar nibrag avatar ovv avatar rutsky avatar sayoun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

aioxmlrpc's Issues

AttributeError when server closes socket

If the XMLRPC server closes the socket, which is rather common if it's Apache, I get this error:

Traceback (most recent call last):
  File "/usr/share/routest/env/lib/python3.5/site-packages/aioxmlrpc/client.py", line 71, in request
    connector=self._connector, loop=self._loop)
  File "/usr/share/routest/env/lib/python3.5/site-packages/aiohttp/client.py", line 605, in __iter__
    return (yield from self._coro)
  File "/usr/share/routest/env/lib/python3.5/site-packages/aiohttp/client.py", line 161, in _request
    raise RuntimeError('Session is closed')
RuntimeError: Session is closed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/share/routest/env/lib/python3.5/site-packages/routest/resource/space/serializers.py", line 159, in check_job_status
    self.job_status = await self.lava.scheduler.job_status(self.job_id)
  File "/usr/share/routest/env/lib/python3.5/site-packages/aioxmlrpc/client.py", line 37, in __call__
    ret = yield from self.__send(self.__name, args)
  File "/usr/share/routest/env/lib/python3.5/site-packages/aioxmlrpc/client.py", line 130, in __request
    verbose=self.__verbose
  File "/usr/share/routest/env/lib/python3.5/site-packages/aioxmlrpc/client.py", line 80, in request
    raise ProtocolError(url, response.status,
AttributeError: 'NoneType' object has no attribute 'status'

Error while using aiohttp 0.20.0

Hello,

I used the example from the readme and it doesn't work with aiohttp in version 0.20.0 (debian jessie version)

It seems related to this http://stackoverflow.com/a/34972564

The full traceback:

Unexpected error
Traceback (most recent call last):
  File "/home/sayoun/.virtualenvs/testtest/lib/python3.4/site-packages/aioxmlrpc/client.py", line 72, in request
    body = yield from response.read_and_close()
AttributeError: 'ClientResponse' object has no attribute 'read_and_close'
Traceback (most recent call last):
  File "/home/sayoun/.virtualenvs/testtest/lib/python3.4/site-packages/aioxmlrpc/client.py", line 72, in request
    body = yield from response.read_and_close()
AttributeError: 'ClientResponse' object has no attribute 'read_and_close'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 13, in <module>
    loop.run_until_complete(print_gandi_api_version())
  File "/usr/lib/python3.4/asyncio/base_events.py", line 337, in run_until_complete
    return future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.4/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "test.py", line 8, in print_gandi_api_version
    result = yield from api.version.info()
  File "/home/sayoun/.virtualenvs/testtest/lib/python3.4/site-packages/aioxmlrpc/client.py", line 37, in __call__
    ret = yield from self.__send(self.__name, args)
  File "/home/sayoun/.virtualenvs/testtest/lib/python3.4/site-packages/aioxmlrpc/client.py", line 124, in __request
    verbose=self.__verbose
  File "/home/sayoun/.virtualenvs/testtest/lib/python3.4/site-packages/aioxmlrpc/client.py", line 81, in request
    str(exc), response.headers)
xmlrpc.client.ProtocolError: <ProtocolError for https://rpc.gandi.net/xmlrpc/: 200 'ClientResponse' object has no attribute 'read_and_close'>
Unclosed response
client_response: <ClientResponse(https://rpc.gandi.net/xmlrpc/) [200 OK]>
<CIMultiDictProxy('DATE': 'Wed, 25 May 2016 20:03:03 GMT', 'SERVER': 'Apache/2.2.16 (Debian) mod_ssl/2.2.16 OpenSSL/0.9.8o mod_wsgi/3.3 Python/2.6.6', 'VARY': 'Accept-Encoding', 'CONTENT-ENCODING': 'gzip', 'CONTENT-LENGTH': '141', 'CONNECTION': 'close', 'CONTENT-TYPE': 'text/xml; charset=utf-8')>

Update dependancies

Hey !

Can you please upgrade dependencies requirements ?

aioxmlrpc 0.7.0 requires httpx<0.25.0,>=0.24.0, but you have httpx 0.27.0 which is incompatible.

Thx

Adapt aioxmlrpc for aiohttp 2.2

Hi,

Thanks a lot for this library, we use it since a long time ago without issues.
However, since we have upgraded our application to aiohttp 2.2, we have an error in our logs each time we use aioxmlrpc, for example:

asyncio:ERROR 2017-08-09 13:26:49,300 base_events.py:1260 => Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f37747ecef0>

aiohttp have changed a lot of points with 2.X:

Is somebody working to upgrade aioxmlrpc for aiohttp 2.2 ?
Or are you interested in by a pull request for that ?

Regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.