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" 
1
  • 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? Commented Jul 6, 2017 at 12:04

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.