AnyDns
An anyio extension featuring compatability of multiple different asynchronous dns resolver libraries. The concept follows the same concept as anyio itself where trio and asyncio can be used either way. This library also adds useful additional tools such as msgspec which can allow you to convert your DNS resuls in whatever way you want or even let you host your own applications with litestar.
Supported Libraries
This library takes c-ares libraries currently but many more implementations could be easily added on in the future as long as they follow the basic concept of anyio support with the ability to run on Windows, Linux and Apple.
Current Usage
Frontend is still being worked on for now but currently picking the library installed should be enough for now.
import anyio
from anydns.cyares import DNSResolver
# this will also work
from anydns.pycares import DNSResolver
async def main():
async with DNSResolver(["8.8.4.4","1.1.1.1"], timeout=2) as r:
info = await r.gethostbyaddr("50.87.249.219")
# HostResult(name='box2079.bluehost.com', aliases=['box2079.bluehost.com'], addresses=['50.87.249.219'])
print(info)
if __name__ == "__main__":
anyio.run(main)
cyares
Cyares is implemented as a backend that uses the .cyares module.
It utilizes c-ares and cython and was made out of pure inspiration of pycares (by the same author of this library even)
with the goal of added features, extreme speed and a few other safety mechanisms.
[!NOTE]
It should be noted that pycares and cyares have event-threads disabled, this was done to prevent the possibilities involving deadlocks and also because anyio supplies it's own selectors for you so you shouldn't ever have to worry about supplying your own read or write selectors.
pip install anydns[cyares]
pycares
Pycares was implemented as a backend that uses the .pycares module.
It utilizes c-ares and cffi. pycares this is also a very mature library with over a decade of maitenence.
[!NOTE]
It should be noted that pycares and cyares have event-threads disabled, this was done to prevent the possibilities involving deadlocks and also because anyio supplies it's own selectors for you so you shouldn't ever have to worry about supplying your own read or write selectors.
pip install anydns[pycares]
Installing everything
If you need to test every single supported backend under the sun when developing your applications (example: testing each one out and checking for bugs) do this
pip install anydns[all]
Adding your library to the current List.
If you have a dns library of your own that you want to include the following criteria must be met.
- must support all operating systems on a PC but mostly the main 3
- Windows, Linux, Apple
- must be compatable with anyio's system
- must be subclassed from
AbstractDNSResolver
Current State
Tests are on my todolist but a release should be coming out soon.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anydns-0.1.0.tar.gz.
File metadata
- Download URL: anydns-0.1.0.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
679d5be07d8be4fe4955380e7acc0b2028732d562727dbe4870ce20727bcbf88
|
|
| MD5 |
cae96b5afb5b6679ff9ce391bd6caca6
|
|
| BLAKE2b-256 |
0426d382e060fcc64788dd857a8025659be618cee5474d01f42867bc9a898aad
|
File details
Details for the file anydns-0.1.0-py3-none-any.whl.
File metadata
- Download URL: anydns-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bc9457e9cea73c63bb4a07075b561e05e705a57423a76905ddd055e2076f912
|
|
| MD5 |
54f3d59dbd896af3851f52a1bd42d61a
|
|
| BLAKE2b-256 |
33e88a2ad36fe4378baf2e38decf541e28bfc4cab987395310688af7c42c189b
|