Skip to content

Commit

Permalink
Prevent mDNS resolver breakage via aiodns
Browse files Browse the repository at this point in the history
aiodns is now the DefaultResolver when installed, and for some reason,
this whole code path doesn't support mDNS resolution.
  • Loading branch information
Graeme Smecher committed Dec 20, 2024
1 parent 0bdb472 commit 406908e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tuber/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,13 @@ async def __call__(self, continue_on_error: bool = False):
# hide import for non-library package that may not be invoked
import aiohttp

# AsyncResolver does not support mDNS
resolver = aiohttp.resolver.ThreadedResolver()

# Monkey-patch tuber session memory handling with the running event loop
loop._tuber_session = aiohttp.ClientSession(json_serialize=Codecs["json"].encode)
loop._tuber_session = aiohttp.ClientSession(
json_serialize=Codecs["json"].encode, connector=aiohttp.TCPConnector(resolver=resolver)
)

# Ensure that ClientSession.close() is called when the loop is
# closed. ClientSession.__del__ does not close the session, so it
Expand Down

0 comments on commit 406908e

Please sign in to comment.