Skip to content

fix: ApiClient finalizer during interpreter shutdown - #720

Merged
karel-rehor merged 3 commits into
influxdata:masterfrom
abhinavrastogi2627:fix/safe-api-client-finalizer
Oct 19, 2026
Merged

karel-rehor merged 3 commits into
influxdata:masterfrom
abhinavrastogi2627:fix/safe-api-client-finalizer

Conversation

@abhinavrastogi2627

Copy link
Copy Markdown
Contributor

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.35%. Comparing base (7ed4ecf) to head (c6462af).
❗ 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.35%   -0.11%     
==========================================
  Files          40       40              
  Lines        3555     3568      +13     
==========================================
+ Hits         3216     3224       +8     
- Misses        339      344       +5     

☔ 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
Contributor 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.

@karel-rehor karel-rehor changed the title Fix ApiClient finalizer during interpreter shutdown fix: ApiClient finalizer during interpreter shutdown Oct 16, 2026

@karel-rehor karel-rehor left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@abhinavrastogi2627 Thank you for this contribution!

Looks good to me. 🚴 🏁

@karel-rehor
karel-rehor merged commit ef60f89 into influxdata:master Oct 19, 2026
14 checks passed
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

3 participants