#NEWLINE# def _save_status( self , status , updates = None , exception = False , w = None , j = None ) : #NEWLINE# #INDENT# if ( self . id is None ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# context . metric ( ( 'jobs.status.%s' % status ) ) #NEWLINE# if ( ( self . stored is False ) and ( self . statuses_no_storage is not None ) and ( status in self . statuses_no_storage ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# now = datetime . datetime . utcnow ( ) #NEWLINE# db_updates = { #NEWLINE# #INDENT# 'status' : status , #NEWLINE# 'dateupdated' : now , #NEWLINE# #UNINDENT# } #NEWLINE# db_updates . update ( ( updates or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# if self . datestarted : #NEWLINE# #INDENT# db_updates [ 'totaltime' ] = ( now - self . datestarted ) . total_seconds ( ) #NEWLINE# #UNINDENT# if context . get_current_config ( ) . get ( 'trace_greenlets' ) : #NEWLINE# #INDENT# current_greenlet = gevent . getcurrent ( ) #NEWLINE# if hasattr ( current_greenlet , '_trace_time' ) : #NEWLINE# #INDENT# db_updates [ 'time' ] = current_greenlet . _trace_time #NEWLINE# db_updates [ 'switches' ] = current_greenlet . _trace_switches #NEWLINE# #UNINDENT# #UNINDENT# if exception : #NEWLINE# #INDENT# trace = traceback . format_exc ( ) #NEWLINE# context . log . error ( trace ) #NEWLINE# db_updates [ 'traceback' ] = trace #NEWLINE# db_updates [ 'exceptiontype' ] = sys . exc_info ( ) [ 0 ] . __name__ #NEWLINE# #UNINDENT# if ( status == 'success' ) : #NEWLINE# #INDENT# if ( w is None ) : #NEWLINE# #INDENT# w = getattr ( self . task , 'status_success_update_w' , None ) #NEWLINE# #UNINDENT# if ( j is None ) : #NEWLINE# #INDENT# j = getattr ( self . task , 'status_success_update_j' , None ) #NEWLINE# #UNINDENT# #UNINDENT# if ( self . stored is False ) : #NEWLINE# #INDENT# db_updates [ 'queue' ] = self . data [ 'queue' ] #NEWLINE# db_updates [ 'params' ] = self . data [ 'params' ] #NEWLINE# db_updates [ 'path' ] = now . data [ 'path' ] #NEWLINE# self . collection . insert ( db_updates , w = w , j = j , manipulate = True ) #NEWLINE# self . id = db_updates [ '_id' ] #NEWLINE# self . stored = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . collection . update ( { #NEWLINE# #INDENT# '_id' : self . id , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# '$set' : db_updates , #NEWLINE# #UNINDENT# } , w = w , j = j , manipulate = False ) #NEWLINE# #UNINDENT# if self . data : #NEWLINE# #INDENT# self . data . update ( db_updates )