Skip to content

Conversation

@bdraco
Copy link
Member

@bdraco bdraco commented Dec 5, 2025

What do these changes do?

Converts _callback from a @staticmethod to an instance method so that the callback holds a strong reference to the resolver instance. This prevents the resolver from being garbage collected while queries are pending.

Are there changes in behavior for the user?

Previously, queries on temporary resolvers would fail:

# Failed with DNSError(24, 'DNS query cancelled')
await DNSResolver().query("example.com", "A")

Now this pattern works correctly because the future's callback keeps the resolver alive until the query completes.

Related issue number

Fixes #209

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.69%. Comparing base (e088cf4) to head (a14c046).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #211      +/-   ##
==========================================
+ Coverage   97.31%   97.69%   +0.37%     
==========================================
  Files           3        3              
  Lines         559      564       +5     
  Branches       38       38              
==========================================
+ Hits          544      551       +7     
+ Misses          8        7       -1     
+ Partials        7        6       -1     

☔ View full report in Codecov by Sentry.
📢 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.

@bdraco bdraco marked this pull request as ready for review December 5, 2025 17:16
@bdraco bdraco merged commit 4cb8ab8 into master Dec 5, 2025
24 checks passed
@bdraco bdraco deleted the callback_strong_ref branch December 5, 2025 17:40
@bdraco bdraco mentioned this pull request Dec 5, 2025
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.

Future returned by DNSResolver.query() does not hold reference to resolver

2 participants