Skip to content

Commit

Permalink
Prevent mDNS resolver breakage via aiodns (#54)
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.

Co-authored-by: Graeme Smecher <[email protected]>
  • Loading branch information
gsmecher and Graeme Smecher authored Dec 20, 2024
1 parent 0bdb472 commit dbfa439
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 dbfa439

Please sign in to comment.