1

I have an Excel spreadsheet of domains that I need to check for a valid MX record. It runs for the first 10 lines, then pauses, then runs again for the next 10 lines, then pauses, then runs for the next 41 lines, then pauses, so there's not really a pattern that's making sense to me.

Do I need to tell it "Hey, if you don't find an mx record in x seconds, move on", or is there a better way entirely of running this code?

import pandas as pd
import dns.resolver

def getListOfDomains():

    data_df= pd.read_excel('check.xlsx') #todo: mainRun passes name of file into run
    df = pd.DataFrame(data_df)
    result= df.drop_duplicates(subset=['domain'])
    for index, row in df.iterrows():
        TryString= str(row['domain'])
         try:
            check= dns.resolver.query(TryString, 'MX')
            print check.response
        except:
            print "No MX here"
Sam W
  • 79
  • 2
  • 8
  • How long should I expect a pause before giving up? Or, how can I edit it so if no response is received in x seconds, continue? – Sam W Jul 06 '17 at 12:04

1 Answers1

0

Question; Do I need to tell it "... x seconds, move on", ...

There is no guarantee that dns.resolver.query(... return immediately.
The Pause is normal behavior awaiting a response

Comment: ... how can I ... if no response is received in x seconds, continue?

Read this SO Answer: Dnspython: Setting query timeout/lifetime

stovfl
  • 14,998
  • 7
  • 24
  • 51