3 ==============================
5 ==============================
7 This example performs the name lookup in the background.
8 The main program keeps running while the name is resolved.
16 ctx = unbound.ub_ctx()
17 ctx.resolvconf("/etc/resolv.conf")
19 def call_back(my_data,status,result):
20 print "Call_back:", my_data
21 if status == 0 and result.havedata:
22 print "Result:", result.data.address_list
23 my_data['done_flag'] = True
26 my_data = {'done_flag':False,'arbitrary':"object"}
27 status, async_id = ctx.resolve_async("www.seznam.cz", my_data, call_back, unbound.RR_TYPE_A, unbound.RR_CLASS_IN)
29 while (status == 0) and (not my_data['done_flag']):
30 status = ctx.process()
34 print "Resolve error:", unbound.ub_strerror(status)
36 The :meth:`unbound.ub_ctx.resolve_async` method is able to pass on any Python object. In this example, we used a dictionary object `my_data`.