jsonrpc-async


Namejsonrpc-async JSON
Version 2.1.2 PyPI version JSON
download
home_pagehttp://github.com/emlove/jsonrpc-async
SummaryA JSON-RPC client library for asyncio
upload_time2023-07-10 16:01:26
maintainer
docs_urlNone
authorEmily Mills
requires_python
licenseBSD
keywords json-rpc async asyncio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            jsonrpc-async: a compact JSON-RPC client library for asyncio
=======================================================================================================

.. image:: https://img.shields.io/pypi/v/jsonrpc-async.svg
        :target: https://pypi.python.org/pypi/jsonrpc-async
.. image:: https://github.com/emlove/jsonrpc-async/workflows/tests/badge.svg
        :target: https://github.com/emlove/jsonrpc-async/actions
.. image:: https://coveralls.io/repos/emlove/jsonrpc-async/badge.svg
    :target: https://coveralls.io/r/emlove/jsonrpc-async

This is a compact and simple JSON-RPC client implementation for asyncio python code. This code is forked from https://github.com/gciotta/jsonrpc-requests

Main Features
-------------

* Supports nested namespaces (eg. `app.users.getUsers()`)
* 100% test coverage

Usage
-----
It is recommended to manage the aiohttp ClientSession object externally and pass it to the Server constructor. `(See the aiohttp documentation.) <https://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ClientSession>`_ If not passed to Server, a ClientSession object will be created automatically.

Execute remote JSON-RPC functions

.. code-block:: python

    import asyncio
    from jsonrpc_async import Server

    async def routine():
        async with Server('http://localhost:8080') as server:
            await server.foo(1, 2)
            await server.foo(bar=1, baz=2)
            await server.foo({'foo': 'bar'})
            await server.foo.bar(baz=1, qux=2)

    asyncio.get_event_loop().run_until_complete(routine())

A notification

.. code-block:: python

    import asyncio
    from jsonrpc_async import Server

    async def routine():
        async with Server('http://localhost:8080') as server:
            await server.foo(bar=1, _notification=True)

    asyncio.get_event_loop().run_until_complete(routine())

Pass through arguments to aiohttp (see also `aiohttp  documentation <http://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ClientSession.request>`_)

.. code-block:: python

    import asyncio
    import aiohttp
    from jsonrpc_async import Server

    async def routine():
        async with Server(
            'http://localhost:8080',
            auth=aiohttp.BasicAuth('user', 'pass'),
            headers={'x-test2': 'true'}
        ) as server:
            await server.foo()

    asyncio.get_event_loop().run_until_complete(routine())

Pass through aiohttp exceptions

.. code-block:: python

    import asyncio
    import aiohttp
    from jsonrpc_async import Server

    async def routine():
        async with Server('http://unknown-host') as server:
            try:
                await server.foo()
            except TransportError as transport_error:
                print(transport_error.args[1]) # this will hold a aiohttp exception instance

    asyncio.get_event_loop().run_until_complete(routine())

Tests
-----
Install the Python tox package and run ``tox``, it'll test this package with various versions of Python.

Changelog
---------
2.1.2 (2023-07-10)
~~~~~~~~~~~~~~~~~~
- Add support for `async with` `(#10) <https://github.com/emlove/jsonrpc-async/pull/10>`_ `@lieryan <https://github.com/lieryan>`_

2.1.1 (2022-05-03)
~~~~~~~~~~~~~~~~~~
- Unpin test dependencies

2.1.0 (2021-05-03)
~~~~~~~~~~~~~~~~~~
- Bumped jsonrpc-base to version 2.1.0

2.0.0 (2021-03-16)
~~~~~~~~~~~~~~~~~~
- Bumped jsonrpc-base to version 2.0.0
- BREAKING CHANGE: `Allow single mapping as a positional parameter. <https://github.com/emlove/jsonrpc-base/pull/6>`_
  Previously, when calling with a single dict as a parameter (example: ``server.foo({'bar': 0})``), the mapping was used as the JSON-RPC keyword parameters. This made it impossible to send a mapping as the first and only positional parameter. If you depended on the old behavior, you can recreate it by spreading the mapping as your method's kwargs. (example: ``server.foo(**{'bar': 0})``)

1.1.1 (2019-11-12)
~~~~~~~~~~~~~~~~~~
- Bumped jsonrpc-base to version 1.0.3

1.1.0 (2018-09-04)
~~~~~~~~~~~~~~~~~~
- Added support for using a custom json.loads method `(#1) <https://github.com/emlove/jsonrpc-async/pull/1>`_ `@tdivis <https://github.com/tdivis>`_

1.0.1 (2018-08-23)
~~~~~~~~~~~~~~~~~~
- Bumped jsonrpc-base to version 1.0.2

1.0.0 (2018-07-06)
~~~~~~~~~~~~~~~~~~
- Bumped minimum aiohttp version to 3.0.0
- Bumped jsonrpc-base to version 1.0.1

Credits
-------
`@gciotta <https://github.com/gciotta>`_ for creating the base project `jsonrpc-requests <https://github.com/gciotta/jsonrpc-requests>`_.

`@mbroadst <https://github.com/mbroadst>`_ for providing full support for nested method calls, JSON-RPC RFC
compliance and other improvements.

`@vaab <https://github.com/vaab>`_ for providing api and tests improvements, better RFC compliance.

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/emlove/jsonrpc-async",
    "name": "jsonrpc-async",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "json-rpc async asyncio",
    "author": "Emily Mills",
    "author_email": "emily@emlove.me",
    "download_url": "https://files.pythonhosted.org/packages/84/ad/207ad0d5f497773354336dbcb490ca6433955d114cd881a3777900db1028/jsonrpc-async-2.1.2.tar.gz",
    "platform": null,
    "description": "jsonrpc-async: a compact JSON-RPC client library for asyncio\n=======================================================================================================\n\n.. image:: https://img.shields.io/pypi/v/jsonrpc-async.svg\n        :target: https://pypi.python.org/pypi/jsonrpc-async\n.. image:: https://github.com/emlove/jsonrpc-async/workflows/tests/badge.svg\n        :target: https://github.com/emlove/jsonrpc-async/actions\n.. image:: https://coveralls.io/repos/emlove/jsonrpc-async/badge.svg\n    :target: https://coveralls.io/r/emlove/jsonrpc-async\n\nThis is a compact and simple JSON-RPC client implementation for asyncio python code. This code is forked from https://github.com/gciotta/jsonrpc-requests\n\nMain Features\n-------------\n\n* Supports nested namespaces (eg. `app.users.getUsers()`)\n* 100% test coverage\n\nUsage\n-----\nIt is recommended to manage the aiohttp ClientSession object externally and pass it to the Server constructor. `(See the aiohttp documentation.) <https://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ClientSession>`_ If not passed to Server, a ClientSession object will be created automatically.\n\nExecute remote JSON-RPC functions\n\n.. code-block:: python\n\n    import asyncio\n    from jsonrpc_async import Server\n\n    async def routine():\n        async with Server('http://localhost:8080') as server:\n            await server.foo(1, 2)\n            await server.foo(bar=1, baz=2)\n            await server.foo({'foo': 'bar'})\n            await server.foo.bar(baz=1, qux=2)\n\n    asyncio.get_event_loop().run_until_complete(routine())\n\nA notification\n\n.. code-block:: python\n\n    import asyncio\n    from jsonrpc_async import Server\n\n    async def routine():\n        async with Server('http://localhost:8080') as server:\n            await server.foo(bar=1, _notification=True)\n\n    asyncio.get_event_loop().run_until_complete(routine())\n\nPass through arguments to aiohttp (see also `aiohttp  documentation <http://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ClientSession.request>`_)\n\n.. code-block:: python\n\n    import asyncio\n    import aiohttp\n    from jsonrpc_async import Server\n\n    async def routine():\n        async with Server(\n            'http://localhost:8080',\n            auth=aiohttp.BasicAuth('user', 'pass'),\n            headers={'x-test2': 'true'}\n        ) as server:\n            await server.foo()\n\n    asyncio.get_event_loop().run_until_complete(routine())\n\nPass through aiohttp exceptions\n\n.. code-block:: python\n\n    import asyncio\n    import aiohttp\n    from jsonrpc_async import Server\n\n    async def routine():\n        async with Server('http://unknown-host') as server:\n            try:\n                await server.foo()\n            except TransportError as transport_error:\n                print(transport_error.args[1]) # this will hold a aiohttp exception instance\n\n    asyncio.get_event_loop().run_until_complete(routine())\n\nTests\n-----\nInstall the Python tox package and run ``tox``, it'll test this package with various versions of Python.\n\nChangelog\n---------\n2.1.2 (2023-07-10)\n~~~~~~~~~~~~~~~~~~\n- Add support for `async with` `(#10) <https://github.com/emlove/jsonrpc-async/pull/10>`_ `@lieryan <https://github.com/lieryan>`_\n\n2.1.1 (2022-05-03)\n~~~~~~~~~~~~~~~~~~\n- Unpin test dependencies\n\n2.1.0 (2021-05-03)\n~~~~~~~~~~~~~~~~~~\n- Bumped jsonrpc-base to version 2.1.0\n\n2.0.0 (2021-03-16)\n~~~~~~~~~~~~~~~~~~\n- Bumped jsonrpc-base to version 2.0.0\n- BREAKING CHANGE: `Allow single mapping as a positional parameter. <https://github.com/emlove/jsonrpc-base/pull/6>`_\n  Previously, when calling with a single dict as a parameter (example: ``server.foo({'bar': 0})``), the mapping was used as the JSON-RPC keyword parameters. This made it impossible to send a mapping as the first and only positional parameter. If you depended on the old behavior, you can recreate it by spreading the mapping as your method's kwargs. (example: ``server.foo(**{'bar': 0})``)\n\n1.1.1 (2019-11-12)\n~~~~~~~~~~~~~~~~~~\n- Bumped jsonrpc-base to version 1.0.3\n\n1.1.0 (2018-09-04)\n~~~~~~~~~~~~~~~~~~\n- Added support for using a custom json.loads method `(#1) <https://github.com/emlove/jsonrpc-async/pull/1>`_ `@tdivis <https://github.com/tdivis>`_\n\n1.0.1 (2018-08-23)\n~~~~~~~~~~~~~~~~~~\n- Bumped jsonrpc-base to version 1.0.2\n\n1.0.0 (2018-07-06)\n~~~~~~~~~~~~~~~~~~\n- Bumped minimum aiohttp version to 3.0.0\n- Bumped jsonrpc-base to version 1.0.1\n\nCredits\n-------\n`@gciotta <https://github.com/gciotta>`_ for creating the base project `jsonrpc-requests <https://github.com/gciotta/jsonrpc-requests>`_.\n\n`@mbroadst <https://github.com/mbroadst>`_ for providing full support for nested method calls, JSON-RPC RFC\ncompliance and other improvements.\n\n`@vaab <https://github.com/vaab>`_ for providing api and tests improvements, better RFC compliance.\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "A JSON-RPC client library for asyncio",
    "version": "2.1.2",
    "project_urls": {
        "Homepage": "http://github.com/emlove/jsonrpc-async"
    },
    "split_keywords": [
        "json-rpc",
        "async",
        "asyncio"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "84ad207ad0d5f497773354336dbcb490ca6433955d114cd881a3777900db1028",
                "md5": "9faaa5c428e8a2e3dd195134a4198893",
                "sha256": "34736694c038e31da578447713922d249cf20ec0ade00c01a27de55569e4ddb1"
            },
            "downloads": -1,
            "filename": "jsonrpc-async-2.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "9faaa5c428e8a2e3dd195134a4198893",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4877,
            "upload_time": "2023-07-10T16:01:26",
            "upload_time_iso_8601": "2023-07-10T16:01:26.451277Z",
            "url": "https://files.pythonhosted.org/packages/84/ad/207ad0d5f497773354336dbcb490ca6433955d114cd881a3777900db1028/jsonrpc-async-2.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-10 16:01:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "emlove",
    "github_project": "jsonrpc-async",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "jsonrpc-async"
}
        
Elapsed time: 0.10464s