def print_user_info(user): print "looking up", user d = mydb.get_user(user) print "still thinking.." def got_info(res): print "name:", res.name reactor.stop() d.addCallback(got_info) print "*still* thinking.."
def get_user_name(user): d = mydb.get_user(user) def extract_name(res): print "extract_name(%r)" % res if res: return res.name return "(unknown)" d.addCallback(extract_name) return d