-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use requests with attested connection pooling #22
Conversation
🦙 MegaLinter status: ✅ SUCCESS
See detailed report in MegaLinter reports You could have the same capabilities but better runtime performances if you use a MegaLinter flavor:
|
2ec487c
to
b7b231c
Compare
from promptguard.authentication import get_api_key | ||
from promptguard.configuration import get_server_config | ||
|
||
_session: Optional[requests.Session] = None | ||
_sessionLock: threading.Lock = threading.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: _session_lock
to match Python naming convention
Some comments about what these variables are used for would also help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
api_key = get_api_key() | ||
hostname, port = get_server_config() | ||
|
||
ctx = AttestedTLSContext(_get_default_validators()) | ||
conn = AttestedHTTPSConnection(hostname, ctx, port) | ||
response = _session.request( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code doesn't handle the case where connection was closed (maybe by remote). Possibly need something like https://github.com/singer-io/tap-skubana/pull/6/files or better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG
fb152f4
to
16db125
Compare
16db125
to
25a2b97
Compare
Overview
This PR updates the PromptGuard client to use the changes proposed to the underlying aTLS package. Namely, this PR modifies the PromptGuard client to use the
requests
library and to utilize the aTLS adapter in the aforementioned PR to in turn gain support for connection pooling, thereby greatly reducing the per-request latency.