Requests session pooling#590
Conversation
|
👋 Hello @username, thank you for submitting an
For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀 |
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review
Made with ❤️ by Ultralytics Actions
Looks good—thanks for introducing shared sessions to improve connection reuse for both GitHub and OpenAI calls.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 2
Made with ❤️ by Ultralytics Actions
The session pooling looks good overall. Please add a way to close the new GitHub session to avoid leaking sockets in long-lived runs.
💬 Posted 1 inline comment
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 3
Made with ❤️ by Ultralytics Actions
Nice step toward connection reuse. Please revisit the shared OpenAI session; using a single module-level requests.Session() can introduce thread-safety issues under concurrent load.
💬 Posted 1 inline comment
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 4
Made with ❤️ by Ultralytics Actions
Please harden the new session cleanup to avoid destructor-time exceptions; otherwise the session reuse looks good.
💬 Posted 1 inline comment
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review 5
Made with ❤️ by Ultralytics Actions
Session pooling is a nice win. Please add an explicit way to close the GitHub session instead of depending on __del__, which is unreliable during interpreter shutdown.
💬 Posted 1 inline comment
| "delete": [200, 204], | ||
| } | ||
|
|
||
| def __del__(self): |
There was a problem hiding this comment.
💡 MEDIUM: Relying on __del__ for resource cleanup is fragile because destructors may not run (or module globals may already be None) during interpreter shutdown. Please expose an explicit close()/context-manager path and call it from the action lifecycle instead of counting on garbage collection.
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Introduce Requests session pooling for GitHub and OpenAI HTTP calls to reduce overhead and improve reliability ⚡️
📊 Key Changes
requests.Session()toGitHubUtilsand route all HTTP methods throughself.session._session = requests.Session()inopenai_utils.pyfor OpenAI requests.(connect=30s, read=600s)for better control.🎯 Purpose & Impact