Skip to content

Fix ApiClient finalizer during interpreter shutdown - #720

Open
abhinavrastogi2627 wants to merge 2 commits into
influxdata:masterfrom
abhinavrastogi2627:fix/safe-api-client-finalizer
Open

abhinavrastogi2627 wants to merge 2 commits into
influxdata:masterfrom
abhinavrastogi2627:fix/safe-api-client-finalizer

Conversation

@abhinavrastogi2627

Copy link
Copy Markdown

Summary

  • prevent ApiClient.__del__ from raising while Python clears client state during interpreter shutdown
  • add coverage for a finalizer invoked after cleanup attributes have been removed

Closes #719

Validation

  • pytest -q tests/test_InfluxDBClientAuthorization.py
  • flake8 --isolated --max-line-length=120 --select=E501 influxdb_client/_sync/api_client.py tests/test_InfluxDBClientAuthorization.py
  • git diff --check

The full pytest -q command was attempted after installing the test, extra, and async dependencies. It requires an InfluxDB server at localhost:8086; collection proceeded, then the integration suite failed at its first server connection because no local server is available.

@codecov-commenter

codecov-commenter commented Oct 12, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.41%. Comparing base (7ed4ecf) to head (4bc8d34).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #720      +/-   ##
==========================================
- Coverage   90.46%   90.41%   -0.05%     
==========================================
  Files          40       40              
  Lines        3555     3568      +13     
==========================================
+ Hits         3216     3226      +10     
- Misses        339      342       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@abhinavrastogi2627

Copy link
Copy Markdown
Author

Addressed the coverage advisory in 4bc8d34 with regression tests for signout failure, thread-pool close/join failures, and HTTP-pool cleanup failure. The tests verify later cleanup still runs and no teardown exception escapes. All executable lines in the changed finalizer (lines 86-106) are covered by the local coverage run.

Validation: python -m coverage run --include='*/influxdb_client/_sync/api_client.py' -m unittest tests.test_InfluxDBClientAuthorization passed all 5 tests; changed-test-file E501 checks and git diff --check passed. No production code changed in this follow-up. The full integration suite still requires the InfluxDB service noted in the PR; I have not claimed a local integration pass or installed the upstream Codecov app.

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.

ApiClient.__del__ triggers shutdown-time exception in influxdb-client 1.50.0

2 participants