aiothrift
Asyncio implementation for thrift protocol, which is heavily based on thriftpy2.
Documentation: https://aiothrift.readthedocs.org/
Installation
$ pip install aiothrift
Usage example
Thrift file
service PingPong {
string ping(),
i64 add(1:i32 a, 2:i64 b),
}
Server
import asyncio
import aiothrift
pingpong_thrift = aiothrift.load('pingpong.thrift', module_name='pingpong_thrift')
class Dispatcher:
def ping(self):
return "pong"
async def add(self, a, b):
await asyncio.sleep(1)
return a + b
async def main():
server = await aiothrift.create_server(pingpong_thrift.PingPong, Dispatcher()))
async with server:
await server.serve_forever()
asyncio.run(main())
Client
import asyncio
import aiothrift
pingpong_thrift = aiothrift.load('pingpong.thrift', module_name='pingpong_thrift')
async def go():
conn = await aiothrift.create_connection(pingpong_thrift.PingPong)
print(await conn.ping())
print(await conn.add(5, 6))
conn.close()
asyncio.run(go())
Or use ConnectionPool
import asyncio
import aiothrift
pingpong_thrift = aiothrift.load('pingpong.thrift', module_name='pingpong_thrift')
async def go():
client = await aiothrift.create_pool(pingpong_thrift.PingPong)
print(await client.ping())
print(await client.add(5, 6))
client.close()
await client.wait_closed()
asyncio.run(go())
It’s just that simple to begin with aiothrift, and you are not forced to use aiothrift on both server and client side. So if you already have a normal thrift server setup, feel free to create an async thrift client to communicate with that server.
Requirements
Python >= 3.7.0
LICENSE
aiothrift is offered under the MIT license.
Metadata
Release files for aiothrift 0.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aiothrift-0.2.7.tar.gz | 12.6 kB | Without provenance | Details for aiothrift-0.2.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiothrift-0.2.7-py3-none-any.whl | Python 3 | none | any | Details for aiothrift-0.2.7-py3-none-any.whl |
Total release size: 26.6 kB
Release files / aiothrift-0.2.7.tar.gz
| Download URL | aiothrift-0.2.7.tar.gz |
|---|---|
| Size | 12.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf1485695aabd206f7cd62eb6472734599955244370e8a560a353fe4f50c8d26
|
|
BLAKE2b-256 checksum How to use checksums |
cb5387777444e5b94f688c64a6374b29679254f403ee859962305b10f7c3b56e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.0 Darwin/21.4.0
|
Release files / aiothrift-0.2.7-py3-none-any.whl
| Download URL | aiothrift-0.2.7-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c239ac54a0a3413df7487c17878c13477fcdc4080f11d24774411c193ce7917c
|
|
BLAKE2b-256 checksum How to use checksums |
9215519131b4c067e331689f8bf7ea4452208191c8730460c41fe9c943b824e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.0 Darwin/21.4.0
|
Security for aiothrift 0.2.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.