Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

asyncio powered HTTP client for bravado

Project Description

bravado-asyncio

Note: This is not a fork or reimplementation of bravado using asynchronous programming (like aiomysql is for PyMySQL). The interface of bravado remains unchanged. If you’re developing fully asynchronous applications, you should use aiobravado instead.

bravado-asyncio is an asynchronous HTTP client for the bravado library. It uses Python’s asyncio and aiohttp internally. It enables you to do concurrent network requests with bravado, similar to the fido client. Unlike fido, bravado-asyncio does not depend on crochet or twisted and uses Python 3’s standard library to implement asynchronous behavior.

aiobravado, the fully asynchronous version of bravado, uses bravado-asyncio internally as HTTP client.

Example usage

If you’re familiar with bravado then all you need to do is switch out (or specify) your HTTP client:

from bravado_asyncio.http_client import AsyncioClient
from bravado.client import SwaggerClient

client = SwaggerClient.from_url(
    'http://petstore.swagger.io/v2/swagger.json',
    http_client=AsyncioClient(),
)
pet = client.pet.getPetById(petId=42).result()

Installation

# This will install bravado-asyncio and bravado
$ pip install bravado-asyncio

# To install bravado-asyncio with the optional cchardet and aiodns packages,
# which are recommended by the underlying aiohttp package
$ pip install bravado-asyncio[aiohttp_extras]

Project status

The project is still work in progress, although it is successfully used in production at Yelp. We have an integration test suite that not only covers bravado-asyncio behavior, but also makes sure that behavior is equal to the (default) synchronous bravado HTTP client. That said, if you find a bug please file an issue!

Internal as well as external interfaces may change at any time currently. That said, since bravado expects the HTTP client to adhere to a specific interface, those parts should be relatively stable.

Development and contributing

Developing bravado-asyncio requires a working installation of Python 3.6 with the virtualenv package being installed. All other requirements will be installed in a virtualenv created in the venv directory. A full run of our testsuite runs the tests against Python 3.5 and 3.6, so if you want that to work you should install Python 3.5 as well.

  1. Run make. This will create the virtualenv you will use for development, with all runtime and development dependencies installed.
  2. If you’re using aactivator then you will be prompted to activate the new environment, please do so. If you prefer not to use aactivator, do source .activate.sh.
  3. Make sure everything is set up correctly by running make test.

Since make test will run tests with Python 3.5 and 3.6, you’ll get an error if only one of them is installed. You can ask tox to run tests with a specific Python version like so:

$ tox -e py35

This will run tests with Python 3.5.

We do run linters that currently require Python 3.6. You can run them with tox -e pre-commit.

Travis (the continuous integration system) will run tests with both Python 3.5 and Python 3.6, so make sure you don’t write code that works on Python 3.6 only.

Great, you’re ready to go! If you have an improvement or bugfix, please submit a pull request.

The event loop

bravado-asyncio creates its own event loop in a separate thread. This is necessary as it is not possible to use the main event loop - it would require a fork of bravado, making its public interface asynchronous. That said, bravado-asyncio and bravado should work well with your existing asyncio application.

You shouldn’t normally need to interact with bravado-asyncio’s event loop. If you do need to do so please use bravado_asyncio.http_client.get_loop() to retrieve it. Note that it won’t be the currently active loop!

License

Written by Stephan Jaensch and licensed under the BSD 3-clause license (see LICENSE.txt).

Release History

This version
History Node

0.4.1

History Node

0.4.0

History Node

0.3.4

History Node

0.3.3

History Node

0.3.2

History Node

0.3.1

History Node

0.3.0

History Node

0.2.0

History Node

0.1.0

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
bravado_asyncio-0.4.1-py3-none-any.whl
(11.3 kB) Copy SHA256 Hash SHA256
py3 Wheel Feb 19, 2018
bravado-asyncio-0.4.1.tar.gz
(7.0 kB) Copy SHA256 Hash SHA256
Source Feb 19, 2018

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting