Deleted Added
full compact
async-lookup.py (249140) async-lookup.py (276605)
1#!/usr/bin/python
2'''
3 async-lookup.py : This example shows how to use asynchronous lookups
4
5 Authors: Zdenek Vasicek (vasicek AT fit.vutbr.cz)
6 Marek Vavrusa (xvavru00 AT stud.fit.vutbr.cz)
7
8 Copyright (c) 2008. All rights reserved.

--- 25 unchanged lines hidden (view full) ---

34'''
35import unbound
36import time
37
38ctx = unbound.ub_ctx()
39ctx.resolvconf("/etc/resolv.conf")
40
41def call_back(my_data,status,result):
1#!/usr/bin/python
2'''
3 async-lookup.py : This example shows how to use asynchronous lookups
4
5 Authors: Zdenek Vasicek (vasicek AT fit.vutbr.cz)
6 Marek Vavrusa (xvavru00 AT stud.fit.vutbr.cz)
7
8 Copyright (c) 2008. All rights reserved.

--- 25 unchanged lines hidden (view full) ---

34'''
35import unbound
36import time
37
38ctx = unbound.ub_ctx()
39ctx.resolvconf("/etc/resolv.conf")
40
41def call_back(my_data,status,result):
42 print "Call_back:", my_data
42 print("Call_back:", my_data)
43 if status == 0 and result.havedata:
43 if status == 0 and result.havedata:
44 print "Result:", result.data.address_list
44 print("Result:", result.data.address_list)
45 my_data['done_flag'] = True
46
47
48my_data = {'done_flag':False,'arbitrary':"object"}
49status, async_id = ctx.resolve_async("www.nic.cz", my_data, call_back, unbound.RR_TYPE_A, unbound.RR_CLASS_IN)
50
51while (status == 0) and (not my_data['done_flag']):
52 status = ctx.process()
53 time.sleep(0.1)
54
55if (status != 0):
45 my_data['done_flag'] = True
46
47
48my_data = {'done_flag':False,'arbitrary':"object"}
49status, async_id = ctx.resolve_async("www.nic.cz", my_data, call_back, unbound.RR_TYPE_A, unbound.RR_CLASS_IN)
50
51while (status == 0) and (not my_data['done_flag']):
52 status = ctx.process()
53 time.sleep(0.1)
54
55if (status != 0):
56 print "Resolve error:", unbound.ub_strerror(status)
56 print("Resolve error:", unbound.ub_strerror(status))