Skip to main content

CI

About

Aiohttp transport for Spyne RPC library.

Requirements:

  • Python 3.8, 3.9, 3.10, 3.11
  • Aiohttp >= 3.9.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.

Metadata

Release files for aiohttp-spyne 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiohttp-spyne 1.6.0
File Size Uploaded
aiohttp_spyne-1.6.0.tar.gz 14.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiohttp-spyne 1.6.0
File Interpreter ABI Platform
aiohttp_spyne-1.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.3 kB

Release files / aiohttp_spyne-1.6.0.tar.gz

Download URL aiohttp_spyne-1.6.0.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2c84719d4706b03d505270d98256542c64954405728902e055d211d9e5249e77
BLAKE2b-256 checksum
How to use checksums
357724de8cb462e0ca812730dd73ab223228168d798cba214f4c92dab4279660
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.0 CPython/3.12.3 Windows/11

Release files / aiohttp_spyne-1.6.0-py3-none-any.whl

Download URL aiohttp_spyne-1.6.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f2bab8e2cb329b90a9fd64cee242d45ca288b43d95257787edf12631da6c432
BLAKE2b-256 checksum
How to use checksums
eb6016c0e9b644bf4e7f7d907dd2d10edca38004664d14bdd8f6262f5dc3d670
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.0 CPython/3.12.3 Windows/11

Release history Release notifications | RSS feed

This release

1.6.0 This release

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page