Package: bravado-asyncio
bravado-asyncioNote: 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 useaiobravadoinstead.bravado-asyncio is an asynchronous HTTP client for thebravado library.
It uses Python’s asyncio andaiohttpinternally. It enables
you to do concurrent network requests with bravado, similar to thefido 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, usesbravado-asynciointernally as HTTP client.Example usageIf you’re familiar with bravado then all you need to do is switch out (or specify) your HTTP client:frombravado_asyncio.http_clientimportAsyncioClientfrombravado.clientimportSwaggerClientclient=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$pipinstallbravado-asyncio# To install bravado-asyncio with the optional cchardet and aiodns packages,
# which are recommended by the underlying aiohttp package$pipinstallbravado-asyncio[aiohttp_extras]Project statusThe project 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!Development and contributingDevelopingbravado-asynciorequires a working installation of Python 3.6 with thevirtualenvpackage being installed.
All other requirements will be installed in a virtualenv created in thevenvdirectory.
We also expectmaketo be installed. If you do not have it and do not want
to install it then please refer to theMakefileas to what commands need to be run for each target.Runmake. This will create the virtualenv you will use for development, with all runtime and development
dependencies installed.If you’re usingaactivatorthen you will be prompted to activate the new
environment, please do so. If you prefer not to use aactivator, dosource .activate.sh.Make sure everything is set up correctly by runningmake test.Sincemake testwill run tests with multiple Python versions, you’ll get an error if one of them can’t be found.
You can ask tox to run tests with a specific Python version like so:$tox-epy38This will run tests with Python 3.8.We do run linters that currently require Python 3.6. You can run them withtox-epre-commit.Travis (the continuous integration system) and Github Actions will run tests with all supported Python versions, on all
supported platforms (Linux, macOS, Windows). Make sure you don’t write code that works only on certain platforms or
Python versions.Great, you’re ready to go! If you have an improvement or bugfix, please submit a pull request.The event loopbravado-asynciocreates 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-asyncioand bravado should work well with your existing asyncio application.You shouldn’t normally need to interact withbravado-asyncio’s event loop. If you do need to do so please usebravado_asyncio.http_client.get_loop()to retrieve it. Note that it won’t be the currently active loop!LicenseWritten by Stephan Jaensch and licensed under the BSD 3-clause license (seeLICENSE.txt).