{"library":"aiodns","code":"import asyncio\nfrom aiodns import DNSResolver\n\nasync def resolve_a_record(hostname):\n    resolver = DNSResolver()\n    try:\n        # query_dns returns native pycares 5.x DNSResult types\n        result = await resolver.query_dns(hostname, 'A')\n        for record in result.answer:\n            print(f\"Hostname: {hostname}, Type: A, Address: {record.data.addr}\")\n    except Exception as e:\n        print(f\"DNS resolution failed for {hostname}: {e}\")\n    finally:\n        # It's important to close the resolver when no longer needed.\n        # For long-lived resolvers, manual closing is often done at application shutdown.\n        resolver.close()\n\nasync def main():\n    await resolve_a_record('google.com')\n    await resolve_a_record('nonexistent.example.com') # Example of a failed lookup\n\nif __name__ == '__main__':\n    asyncio.run(main())","lang":"python","description":"This quickstart demonstrates how to perform an asynchronous 'A' record DNS lookup using the `DNSResolver` class and its recommended `query_dns` method. It includes basic error handling and shows the crucial step of closing the resolver to release resources.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}