#NEWLINE# @ tornado . gen . coroutine #NEWLINE# def upload_batch( upload_data_txt ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# request = tornado . httpclient . HTTPRequest ( ( tornado . options . options . es_url + '/_bulk' ) , method = 'POST' , body = upload_data_txt , request_timeout = tornado . options . options . http_upload_timeout ) #NEWLINE# response = ( yield async_http_client . fetch ( request ) ) #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# logging . error ( ( 'upload failed, error: %s' % ex ) ) #NEWLINE# return #NEWLINE# #UNINDENT# result = json . loads ( response . body ) #NEWLINE# res_txt = ( 'OK' if ( not result [ 'errors' ] ) else 'FAILED' ) #NEWLINE# took = int ( result [ 'took' ] ) #NEWLINE# batch_upload_took . append ( took ) #NEWLINE# logging . info ( ( 'Upload: %s - upload took: %5dms, total docs uploaded: %7d' % ( res_txt , took , upload_data_count ) ) )