为什么使用 dnspython 检查 MX 会出现超时错误?

问题描述

import dns.resolver
import concurrent.futures
domains=open('com 2021-6-7 domains.txt',encoding='utf-8').read().splitlines()[0:10000]


mx_domains=[]


def check(domain):
    try:
        answers = dns.resolver.resolve(domain,'MX')
        print('MX EXISTS')
        mx_domains.append(domain)
    except Exception as e:
        print(e)
        print('No MX')




with concurrent.futures.ThreadPoolExecutor(max_workers=500) as executor:
    executor.map(check,domains)

为什么这段代码会报错:

The DNS operation timed out after 5.005800008773804 seconds

还有没有办法解决这个问题,或者有更好的方法吗?还是与我的网络有关? 我是网络领域的新手,所以我无法理解为什么这会导致超时错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)