Debian Codegraph @

/

debian aiohttp-asyncmdnsresolver 0.2.0-1debian python3-aiohttp-asyncmdnsresolver python aiohttp-asyncmdnsresolver 0.2.0 debianinimakemakefilepythonpythonshelltomlyaml 38 files · 366 symbols
View dependency graph

Depends on

README (full)

aiohttp-asyncmdnsresolver

:target: https://github.com/aio-libs/aiohttp-asyncmdnsresolver/actions?query=workflow%3ACI :align: right

:target: https://codecov.io/gh/aio-libs/aiohttp-asyncmdnsresolver

:target: https://badge.fury.io/py/aiohttp-asyncmdnsresolver

:target: https://aiohttp-asyncmdnsresolver.readthedocs.io

:target: https://pypi.org/p/aiohttp-asyncmdnsresolver

 Matrix Room — #aio-libs:matrix.org
 Matrix Space — #aio-libs-space:matrix.org

Introduction

This module provides an aiohttp resolver that supports mDNS, which uses the zeroconf library to resolve mDNS queries.

For full documentation please read https://aiohttp-asyncmdnsresolver.readthedocs.io.

Installation

$ pip install aiohttp-asyncmdnsresolver

Quick start

import asyncio
import aiohttp
from aiohttp_asyncmdnsresolver.api import AsyncMDNSResolver

async def main():
    resolver = AsyncMDNSResolver()
    # aiohttp does not own a resolver passed to TCPConnector, so close it here.
    try:
        connector = aiohttp.TCPConnector(resolver=resolver)
        async with aiohttp.ClientSession(connector=connector) as session:
            async with session.get('http://example.com') as response:
                print(response.status)
            async with session.get('http://xxx.local.') as response:
                print(response.status)
    finally:
        await resolver.close()

asyncio.run(main())

Resolving with both mDNS and DNS

AsyncDualMDNSResolver is a variant that resolves .local names over mDNS and regular DNS concurrently, returning the first successful result. Use it when a .local name may be served by a unicast DNS server as well as mDNS.

import asyncio
import aiohttp
from aiohttp_asyncmdnsresolver.api import AsyncDualMDNSResolver

async def main():
    resolver = AsyncDualMDNSResolver()
    # aiohttp does not own a resolver passed to TCPConnector, so close it here.
    try:
        connector = aiohttp.TCPConnector(resolver=resolver)
        async with aiohttp.ClientSession(connector=connector) as session:
            async with session.get('http://printer.local.') as response:
                print(response.status)
    finally:
        await resolver.close()

asyncio.run(main())

API documentation

The documentation is located at https://aiohttp-asyncmdnsresolver.readthedocs.io.

Source code

The project is hosted on GitHub

Please file an issue on the bug tracker if you have found a bug or have some suggestion in order to improve the library.

Authors and License

It's Apache 2 licensed and freely available.

dir .github/
dir CHANGES/
dir debian/
dir docs/
dir examples/
dir requirements/
dir src/
dir tests/
file .codecov.yml
file .coveragerc
file .gitignore
file .mypy.ini
file .pre-commit-config.yaml
file .readthedocs.yaml
file .yamllint
file CHANGES.rst
file LICENSE
file MANIFEST.in
file Makefile
file README.rst
file pyproject.toml
file pytest.ini
file towncrier.toml