#NEWLINE# def __exit__( self , * args ) : #NEWLINE# #INDENT# self . profile . disable ( ) #NEWLINE# logging . info ( 'Stop profiling: %s' , self . profile_id ) #NEWLINE# if self . profile_location : #NEWLINE# #INDENT# dump_location = os . path . join ( self . profile_location , 'profile' , ( '%s-%s' % ( time . strftime ( '%Y-%m-%d_%H_%M_%S' ) , self . profile_id ) ) ) #NEWLINE# ( fd , filename ) = tempfile . mkstemp ( ) #NEWLINE# self . profile . dump_stats ( fd ) #NEWLINE# logging . info ( 'Copying profiler data to: [%s]' , dump_location ) #NEWLINE# _dependency_file_copy ( filename , dump_location ) #NEWLINE# os . close ( fd ) #NEWLINE# os . remove ( filename ) #NEWLINE# #UNINDENT# if self . log_results : #NEWLINE# #INDENT# s = StringIO . StringIO ( ) #NEWLINE# self . stats = pstats . Stats ( self . profile , stream = s ) . sort_stats ( Profile . SORTBY ) #NEWLINE# self . stats . print_stats ( ) #NEWLINE# logging . info ( 'Profiler data: [%s]' , s . getvalue ( ) )