fix: document suppressed client cleanup errors#3436
Open
nightcityblade wants to merge 1 commit into
Open
Conversation
nomiveritas
reviewed
Jun 27, 2026
nomiveritas
left a comment
There was a problem hiding this comment.
@nightcityblade I am reviewing this Pull Request and cannot approve these changes as currently submitted due to structural and technical concerns regarding codebase quality:
- Redundant Logic: Adding an explicit
returnstatement at the end of anexcept Exception:block inside a Python destructor (__del__) is redundant. Python functions implicitly returnNoneupon reaching the end of their execution path. This change adds dead code without altering execution behavior. - Guidance for the Root Cause (#3428): Simply replacing
passwith a comment and a redundant return statement suppresses the exception silently without diagnosing the lifecycle issue. To properly resolve this, you should implement structured logging within the exception handler. Consider importing and utilizing the standardlogginglibrary to log the cleanup failure at aDEBUGorWARNINGlevel (e.g.,logger.debug("Failed to clear client resources during destruction: %s", e)). This ensures the exception remains non-blocking for the garbage collector while providing critical visibility into infrastructure errors.
Please refactor this PR to include proper diagnostics instead of cosmetic placeholder statements. Let's ensure the implementation meets proper engineering standards.
Respectfully Nomiveritas
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.
Changes being requested
Replace empty
except Exception: passhandlers in the sync and async HTTP client wrapper destructors with explicit comments andreturnstatements. This keeps destructor cleanup failures suppressed intentionally while making the behavior clear.Fixes #3428
Additional context & links
Tests run:
ruff check src/openai/_base_client.pyruff format --check src/openai/_base_client.pygit diff --checkpytest tests/test_client.py::TestOpenAI::test_parse_retry_after_header tests/test_client.py::TestAsyncOpenAI::test_parse_retry_after_header(32 passed)