feat(async-client): add session pooling for connection reuse TAV-4105#154
Closed
tinosattavily wants to merge 2 commits into
Closed
feat(async-client): add session pooling for connection reuse TAV-4105#154tinosattavily wants to merge 2 commits into
tinosattavily wants to merge 2 commits into
Conversation
- Replace per-request client creation with persistent httpx.AsyncClient - Add close(), __aenter__, __aexit__ for lifecycle management - Extract duplicated error handling into _handle_error_response() - Add _post() helper for centralized request logic - Consolidate _method/method pairs into single public methods - Add test_session_pooling.py with 9 edge case tests - Fix test_errors.py fixture crash when TAVILY_API_KEY unset Performance: 2-10x faster for sequential requests (TCP connection reuse) Code reduction: 786 → 476 lines (39% smaller) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Closing to create a new PR with reverted code simplification changes (keeping only session pooling) |
Contributor
Author
|
Closing to create a new PR with reverted code simplification (keeping only session pooling feature) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
httpx.AsyncClientcreation with persistent client for TCP connection reuseclose(),__aenter__,__aexit__for proper resource cleanuptest_session_pooling.pytest_errors.pyfixture crash whenTAVILY_API_KEYunsetPerformance
Code Reduction
Changes
tavily/async_tavily.py_client_creatorlambda →self._clientpersistent instance_handle_error_response()- centralized error handling_post()- centralized POST + timeout logic_handle_stream_error()- streaming error handling_search/search,_extract/extract, etc. into single methodstests/test_session_pooling.py(NEW)close()method teststests/test_errors.pyset_api_keyfixture that crashed when env var was not setTest plan
Fixes TAV-4105
🤖 Generated with Claude Code