Database Reference
In-Depth Information
# try again.
if err.resp.status in [403, 500, 503]:
print '%s: Retryable error %s, waiting' % (
self.thread_id, err.resp.status,)
time.sleep(5)
else: raise
def read(self, result_handler, snapshot_time=None):
'''Reads an entire table until the end or we hit a
row limit.'''
# Read the current time and use that for the
snapshot time.
# This will prevent us from getting inconsistent
results when the
# underlying table is changing.
if snapshot_time is None and not '@' in
self.table_id:
self.snapshot_time = int(time.time() * 1000)
self.snapshot_time = snapshot_time
while True:
is_done, rows = self.read_one_page()
if rows:
result_handler.handle_rows(rows)
if is_done:
return
class FileResultHandler(ResultHandler):
'''Result handler that saves rows to a file.'''
def __init__(self, output_file_name):
self.output_file_name = output_file_name
print 'Writing results to %s' % (output_file_name,)
def __enter__(self):
self.make_output_dir()
self.output_file = open(self.output_file_name,
'w')
Search WWH ::




Custom Search