MCPcopy Create free account
hub / github.com/catchpoint/WebPageTest.tsproxy / AsyncDNS

Class AsyncDNS

tsproxy.py:192–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190# Threaded DNS resolver
191########################################################################################################################
192class AsyncDNS(threading.Thread):
193 def __init__(self, client_id, hostname, port, is_localhost, result_pipe):
194 threading.Thread.__init__(self)
195 self.hostname = hostname
196 self.port = port
197 self.client_id = client_id
198 self.is_localhost = is_localhost
199 self.result_pipe = result_pipe
200
201 def run(self):
202 global lock, background_activity_count
203 try:
204 logging.debug('[{0:d}] AsyncDNS - calling getaddrinfo for {1}:{2:d}'.format(self.client_id, self.hostname, self.port))
205 addresses = socket.getaddrinfo(self.hostname, self.port)
206 logging.info('[{0:d}] Resolving {1}:{2:d} Completed'.format(self.client_id, self.hostname, self.port))
207 except:
208 addresses = ()
209 logging.info('[{0:d}] Resolving {1}:{2:d} Failed'.format(self.client_id, self.hostname, self.port))
210 message = {'message': 'resolved', 'connection': self.client_id, 'addresses': addresses, 'localhost': self.is_localhost}
211 self.result_pipe.SendMessage(message, False)
212 lock.acquire()
213 if background_activity_count > 0:
214 background_activity_count -= 1
215 lock.release()
216 # open and close a local socket which will interrupt the long polling loop to process the message
217 s = socket.socket()
218 s.connect((server.ipaddr, server.port))
219 s.close()
220
221
222########################################################################################################################

Callers 1

HandleResolveMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected