(conn, sleep_interval, table_name, put_requests)
Write data to table_name
Write data to table_name
Write data to table_name
def batch_write(conn, sleep_interval, table_name, put_requests):
    """
    Write data to table_name
    """

    request_items = {table_name: put_requests}
    i = 1
    sleep = sleep_interval
    while True:
        response = conn.batch_write_item(RequestItems=request_items)
        unprocessed_items = response["UnprocessedItems"]

        if len(unprocessed_items) == 0:
            break
        if len(unprocessed_items) > 0 and i <= MAX_RETRY:
            logging.debug(
                str(len(unprocessed_items))
                + " unprocessed items, retrying after %s seconds.. [%s/%s]"
                % (str(sleep), str(i), str(MAX_RETRY))
            )
            request_items = unprocessed_items
            time.sleep(sleep)
            sleep += sleep_interval
            i += 1
        else:
            logging.info(
                "Max retries reached, failed to processed batch write: "
                + json.dumps(unprocessed_items, indent=JSON_INDENT)
            )
            logging.info("Ignoring and continuing..")
            break
def batch_write ( conn , sleep_interval , table_name , put_requests ) : request_items = { table_name : put_requests } i = 1 sleep = sleep_interval while True : response = conn . batch_write_item ( RequestItems = request_items ) unprocessed_items = response [ "UnprocessedItems" ] if len ( unprocessed_items ) == 0 : break if len ( unprocessed_items ) > 0 and i <= MAX_RETRY : logging . debug ( str ( len ( unprocessed_items ) ) + " unprocessed items, retrying after %s seconds.. [%s/%s]" % ( str ( sleep ) , str ( i ) , str ( MAX_RETRY ) ) ) request_items = unprocessed_items time . sleep ( sleep ) sleep += sleep_interval i += 1 else : logging . info ( "Max retries reached, failed to processed batch write: " + json . dumps ( unprocessed_items , indent = JSON_INDENT ) ) logging . info ( "Ignoring and continuing.." ) break