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