Skip to main content

Aiohttp transport for Spyne RPC library

Project description

About


Aiohttp transport for Spyne RPC library.

Requirements:

  • Python >= 3.7

  • Aiohttp >= 3.7.0

  • Spyne >= 2.14.0

Spyne alpha versions should also work.

Installation


Just run pip install aiohttp-spyne :)

Examples


  • Test server: python -m examples.hello_world

  • Threaded test server: python -m examples.hello_world_threads

  • Test client: python -m examples.test_client

Usage


First, initialize your spyne application as normal. Here’s an example

for a simple SOAP service (See examples for a more complete service setup).

spyne_app = spyne.Application(

    [HelloWorldService],

    tns='aiohttp_spyne.examples.hello',

    in_protocol=Soap11(validator='lxml'),

    out_protocol=Soap11())

Next, wrap your Spyne application with AIOSpyne. Note that you can run

your application entrypoints in a thread by setting the threads parameter.

If you want to keep your entrypoints running in the same thread as the

main application, just leave this None. If you DO run your entrypoints

in threads, be aware that some signals sent by spyne will also be run

in threads, and be extra careful of using your main loop!

handler = AIOSpyne(spyne_app, threads=25)

Lastly, make an aiohttp application as usual, and just bind GET and POST

entrypoints from AIOSpyne to wherever. Note that both paths need to be

the same.

With GET, if the request address ends ?wsdl or .wsdl, a WSDL schema is

returned in a response. Otherwise requests are redirected to spynes

RPC handler.

app = web.Application()

app.router.add_get('/{tail:.*}', handler.get)

app.router.add_post('/{tail:.*}', handler.post)

web.run_app(app, port=8080)

Chunked encoding


If you offer large resultsets in your soap entrypoints, and yield

the results properly, you may want to enable chunked encoding. This

way the aiohttp server can stream your results and reduce memory

usage.

handler = AIOSpyne(spyne_app, chunked=True)

WSDL caching


By default, aiohttp-spyne will cache WSDL documents generated by spyne.

This makes it cheap to offer the WSDL documents to any clients. Sometimes

you may need to disable this caching however (eg. when you have requests

coming from multiple source urls, and want to automatically generate

the port address for each one). This can be done by settings the cache_wsdl

option as False.

handler = AIOSpyne(spyne_app, cache_wsdl=False)

Testing and formatting


  1. pytest

  2. mypy -p aiohttp_spyne

  3. flake8

  4. black aiohttp_spyne/

License


LGPL-2.1 – Please see LICENSE for details.

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

aiohttp-spyne-1.4.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

aiohttp_spyne-1.4.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file aiohttp-spyne-1.4.0.tar.gz.

File metadata

  • Download URL: aiohttp-spyne-1.4.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for aiohttp-spyne-1.4.0.tar.gz
Algorithm Hash digest
SHA256 27b9465af3c4abef97c2f3e29cbc59108c92780b931e46508eb721978b63b707
MD5 6cb9a708ccbe4fecd45ce4acbb19b209
BLAKE2b-256 606bb7cd55a874492996be032abc7f14404e13c0bcd8387de635ebd76acd54c9

See more details on using hashes here.

Provenance

File details

Details for the file aiohttp_spyne-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: aiohttp_spyne-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for aiohttp_spyne-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3fe0392673ad19292fcee34ec54b353a5cc87cfc7f37f331f76f40c80cf87411
MD5 52d8d95a700027424bfb58b643648e38
BLAKE2b-256 2a358a23b234795ffd593aee5b8b7b187d0562676b9022fa037687569c48902b

See more details on using hashes here.

Provenance

Supported by

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