This package is provides an alternative HTTP client for ThriftPy2 which uses HTTPX instead of the builtin http.client and http.server libraries. This allows the developer to use more complex features like authentication, fine grained timeouts, and asyncio.
Examples:
Setup (Borrowed from ThriftPy2 Docs):
# pingpong.thrift
service PingPong {
string ping(),
}
import thriftpy2
from thriftpy2.http import make_server
pingpong_thrift = thriftpy2.load(
"pingpong.thrift",
module_name="pingpong_thrift",
)
class Dispatcher(object):
def ping(self):
return "pong"
server = make_server(
service=pingpong_thrift.PingPong,
handler=Dispatcher(),
host='127.0.0.1',
port=6000,
)
server.serve()
Async Usage:
from thriftpy2_httpx_client import make_aio_client
client = await make_aio_client(pingpong_thrift, url='http://localhost:6000')
print(await client.ping()) # prints 'pong'
Sync Usage:
from thriftpy2_httpx_client import make_sync_client
client = make_sync_client(pingpong_thrift, url='http://localhost:6000')
print(client.ping()) # prints 'pong'
Additional keyword arguments can be passed to the client to configure the internal httpx.AsyncClient() and httpx.Client() instances. For example, you can enable Kerberos authentication using httpx-gssapi:
from httpx_gssapi import HTTPSPNEGOAuth
from thriftpy2_httpx_client import make_aio_client
client = await make_aio_client(
pingpong_thrift,
url='http://localhost:6000',
auth=HTTPSPNEGOAuth(),
)
print(await client.ping()) # prints 'pong'
Metadata
Release files for thriftpy2-httpx-client 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| thriftpy2_httpx_client-0.5.tar.gz | 28.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| thriftpy2_httpx_client-0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.1 kB
Release files / thriftpy2_httpx_client-0.5.tar.gz
| Download URL | thriftpy2_httpx_client-0.5.tar.gz |
|---|---|
| Size | 28.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91a892d6f5a5796f4ff2e72bab4e2bd812d18c92460d9d772c9154c2ecbbf413
|
|
BLAKE2b-256 checksum How to use checksums |
01d34bb2c0d1eb83b11edba9161292a2b9c9207aeac073a51b09cc4b6c72fad9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / thriftpy2_httpx_client-0.5-py3-none-any.whl
| Download URL | thriftpy2_httpx_client-0.5-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a44ba4c8a6ef55ad65fe413fab0dfb3859ca20a2740d5d8936cfbcfdfd02165
|
|
BLAKE2b-256 checksum How to use checksums |
78912316c3182663746eaefbe5b41fbc047302b0705b037fce22653037494bf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|