Skip to main content

Aiohttp transport for Spyne RPC library

Project description

CI

About

Aiohttp transport for Spyne RPC library.

Requirements:

  • Python 3.7, 3.8, 3.9, 3.10, 3.11
  • 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 spyne examples and documentation 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 result sets 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. If for some reason you want to disable this caching, you can do so by setting the cache_wsdl argument as False.

handler = AIOSpyne(spyne_app, cache_wsdl=False)

Testing and formatting

  1. pytest
  2. mypy -p aiohttp_spyne
  3. 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.5.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

aiohttp_spyne-1.5.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file aiohttp_spyne-1.5.0.tar.gz.

File metadata

  • Download URL: aiohttp_spyne-1.5.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.2 Windows/10

File hashes

Hashes for aiohttp_spyne-1.5.0.tar.gz
Algorithm Hash digest
SHA256 e14625b12fc5e9f1ee41d84904d9a2f8513dfe569310cf877e6b48cf0789e2df
MD5 eb7b16f2dc4140f990ed1d5847c24779
BLAKE2b-256 9259f816b6dc171cd885b355d49ea9b6b6c037e35d81c2471bbdd7def3a6abfb

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: aiohttp_spyne-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.2 Windows/10

File hashes

Hashes for aiohttp_spyne-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 588d497fe572f2fdee914be443ccd7e17484c4a8fd6c7bd5666254f2a77cb5a4
MD5 c0337df1efd2e105c5423183874e04a1
BLAKE2b-256 e10784e69785c9f9d21bce40b51f65be8fac6c0bcf20ad3ed4114954a8083a6f

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