Skip to content

fix: close old HTTP client in RegistryTEEConnection.reconnect()#260

Open
teyrebaz33 wants to merge 1 commit intoOpenGradient:mainfrom
teyrebaz33:fix/registry-tee-connection-close-old-http-client
Open

fix: close old HTTP client in RegistryTEEConnection.reconnect()#260
teyrebaz33 wants to merge 1 commit intoOpenGradient:mainfrom
teyrebaz33:fix/registry-tee-connection-close-old-http-client

Conversation

@teyrebaz33
Copy link
Copy Markdown

Summary

Fixes #247

Problem

RegistryTEEConnection.reconnect() was replacing self._active with a new connection without closing the old HTTP client first. In long-running apps that reconnect frequently (e.g. every 5 minutes), this leaks file descriptors and can eventually exhaust system resources.

Fix

Applied the same pattern already used in StaticTEEConnection.reconnect():

  1. Save the old HTTP client reference before reconnecting
  2. Establish the new connection
  3. aclose() the old client after successful reconnect

Changes

  • src/opengradient/client/tee_connection.py: Fixed RegistryTEEConnection.reconnect() to close old HTTP client

Fixes OpenGradient#247

RegistryTEEConnection.reconnect() was replacing self._active without
closing the old HTTP client, leaking file descriptors on long-running
apps that reconnect frequently.

StaticTEEConnection.reconnect() already handled this correctly.
Applied the same pattern: save old_client before reconnecting,
then aclose() it after the new connection is established.
Copy link
Copy Markdown
Collaborator

@kylexqian kylexqian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix, thanks for the contribution!

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.

reconnect() not closing old HTTP client

2 participants