I am trying to iterate on a method and passing others arguments that the method needs. To do so, I think my best shot is to use map() method.
More precisely, I need performs several dns requests (A / AAAA / NS / MX) on several FQDN (Fully Qualified Domain Name, ie: www.mywebsite.com).
As requests can wait few seconds waiting for an answer, I am using threads to compensate.
Here is my actual code :
with ThreadPoolExecutor(max_workers=4) as executor:
for fqdn in fqdn_list:
future_01 = executor.submit(get_dns_query, fqdn, 'A')
future_02 = executor.submit(get_dns_query, fqdn, 'AAAA')
ip = future_01.result()
ipv6 = future_02.result()
Now what I think is best:
with ThreadPoolExecutor(max_workers=4) as executor:
ip = executor.map(get_dns_query, fqdn, 'A')
ipv6 = executor.submit(get_dns_query, fqdn, 'AAAA')
get_dns_query will perform a dns request and requires FQDN and RDTYPE (A / AAAA / NS / MX)
I want map() to iterate on FQDN and I also want to be able to pass RDTYPE as a normal argument.
So far, I understood that it is not the purpose of map. But solutions seems to exist: Functools or Itertools solutions
Unfortunately, I am not able to understand them and if they are applicable to my case.
Any ideas?