#NEWLINE# @ with_low_priority #NEWLINE# def do_part( self , seq , **kwargs ) : #NEWLINE# #INDENT# ' transfer a part. runs in a separate process. ' #NEWLINE# key = None #NEWLINE# for attempt in range ( self . retries ) : #NEWLINE# #INDENT# getLogger ( ) . debug ( 'attempt %d/%d to transfer part %d' , attempt , self . retries , seq ) #NEWLINE# with self . source . chunkfile ( seq , ** kwargs ) as part : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# def cb( tx , total ) : #NEWLINE# #INDENT# readControl ( ) #NEWLINE# make_progress ( { #NEWLINE# #INDENT# 'part' : seq , #NEWLINE# 'tx' : tx , #NEWLINE# 'total' : total , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# if hasattr ( self . upload , 'upload_part_from_file' ) : #NEWLINE# #INDENT# key = self . upload . upload_part_from_file ( fp = part , part_num = ( seq + 1 ) , cb = cb , num_cb = 100 , size = self . source . chunksize ( seq ) , md5 = part . hash ) #NEWLINE# getLogger ( ) . debug ( 'uploaded multi part key %s/%d' , key , ( seq + 1 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . upload . set_contents_from_file ( fp = part , cb = cb , num_cb = 100 , md5 = part . hash ) #NEWLINE# key = self . upload #NEWLINE# getLogger ( ) . debug ( 'uploaded single part key %s' , key ) #NEWLINE# #UNINDENT# #UNINDENT# except PauseEvent : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# except Exception as exc : #NEWLINE# #INDENT# getLogger ( ) . debug ( 'exception while uploading part %d' , seq , exc_info = True ) #NEWLINE# if ( self == ( self . retries - 1 ) ) : #NEWLINE# #INDENT# raise exc #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# getLogger ( ) . debug ( 'succesfully uploaded %s part %d: %s' , self . source , seq , key ) #NEWLINE# return key