Skip to content

fix(http_request): enable TCP keepalive on shared sync session pool - #187

Merged
lzsweb merged 3 commits into
mainfrom
dev/issues-7-1
Sep 4, 2026
Merged

fix(http_request): enable TCP keepalive on shared sync session pool#187
lzsweb merged 3 commits into
mainfrom
dev/issues-7-1

Conversation

@luk384090-cloud

@luk384090-cloud luk384090-cloud commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator
  • Implement TCP keepalive socket options for connection pools
  • Create custom HTTPAdapter to apply keepalive options
  • Lazily create and reuse a shared requests.Session with keepalive
  • Add function to close and reset the shared session pool
  • Register session close on interpreter exit to release connections
  • Add unit tests for keepalive options and session lifecycle management
  • Ensure platform fallback for keepalive socket options
  • Validate session reuse and correct closing behavior in tests

Description

[Describe what this PR does and why]

Related Issue: Fixes #186 ]or Relates to #186

Security Considerations: [Check if API keys or sensitive credentials are exposed in code/logs]

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactoring

Component(s) Affected

  • Model
  • Application
  • Common
  • Documentation
  • Tests
  • CI/CD

Checklist

  • Pre-commit hooks pass
  • Tests pass locally
  • Documentation updated (if needed)
  • Ready for review

Testing

[How to test these changes]

Additional Notes

[Optional: any other context]

- Implement TCP keepalive socket options for connection pools
- Create custom HTTPAdapter to apply keepalive options
- Lazily create and reuse a shared requests.Session with keepalive
- Add function to close and reset the shared session pool
- Register session close on interpreter exit to release connections
- Add unit tests for keepalive options and session lifecycle management
- Ensure platform fallback for keepalive socket options
- Validate session reuse and correct closing behavior in tests
Comment thread tests/unit/test_sync_custom_session.py Outdated
luk384090-cloud and others added 2 commits September 4, 2026 14:26
Mirror the existing close_shared_aio_session export so long-running
applications can manage the shared sync connection pool via
dashscope.close_shared_sync_session() (relates to #186).
@lzsweb
lzsweb merged commit 6bf0851 into main Sep 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shared synchronous Session may cause 300-second stalls on silently stale pooled connections

2 participants