6 This example shows how to use unbound module from a threaded program.
7 In this example, three lookup threads are created which work in background.
8 Each thread resolves different DNS record.
16 from unbound import ub_ctx, RR_TYPE_A, RR_CLASS_IN
17 from threading import Thread
20 ctx.resolvconf("/etc/resolv.conf")
22 class LookupThread(Thread):
23 def __init__(self,ctx, name):
29 print "Thread lookup started:",self.name
30 status, result = self.ctx.resolve(self.name, RR_TYPE_A, RR_CLASS_IN)
31 if status == 0 and result.havedata:
32 print " Result:",self.name,":", result.data.address_list
35 for name in ["www.fit.vutbr.cz","www.vutbr.cz","www.google.com"]:
36 thread = LookupThread(ctx, name)
38 threads.append(thread)
40 for thread in threads: