Skip to content

fix: document suppressed client cleanup errors#3436

Open
nightcityblade wants to merge 1 commit into
openai:mainfrom
nightcityblade:fix/issue-3428
Open

fix: document suppressed client cleanup errors#3436
nightcityblade wants to merge 1 commit into
openai:mainfrom
nightcityblade:fix/issue-3428

Conversation

@nightcityblade

Copy link
Copy Markdown
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Replace empty except Exception: pass handlers in the sync and async HTTP client wrapper destructors with explicit comments and return statements. 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.py
  • ruff format --check src/openai/_base_client.py
  • git diff --check
  • pytest tests/test_client.py::TestOpenAI::test_parse_retry_after_header tests/test_client.py::TestAsyncOpenAI::test_parse_retry_after_header (32 passed)

@nightcityblade nightcityblade requested a review from a team as a code owner June 24, 2026 03:12

@nomiveritas nomiveritas left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@nightcityblade I am reviewing this Pull Request and cannot approve these changes as currently submitted due to structural and technical concerns regarding codebase quality:

  1. Redundant Logic: Adding an explicit return statement at the end of an except Exception: block inside a Python destructor (__del__) is redundant. Python functions implicitly return None upon reaching the end of their execution path. This change adds dead code without altering execution behavior.
  2. Guidance for the Root Cause (#3428): Simply replacing pass with 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 standard logging library to log the cleanup failure at a DEBUG or WARNING level (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

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.

Empty exception handler in _base_client.py

2 participants