Changeset 783


Ignore:
Timestamp:
03/31/13 21:35:31 (11 years ago)
Author:
ramonb
Message:
  • make sure finished jobs get removed from jobAttrsSaved to prevent memory leak
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.4/jobarchived/jobarchived.py

    r782 r783  
    889889        """When all metrics have gone, check if any jobs have finished"""
    890890
     891        jobs_finished = [ ]
     892
    891893        debug_msg( 1, "XML: Processed "+str(self.elementct)+ " elements - found "+str(len(self.jobs_processed))+" jobs" )
    892894
     
    908910
    909911                elif jobid not in self.jobs_processed:
     912
    910913                    # Was running previous heartbeat but not anymore: must be finished
    911914                    self.jobAttrs[ jobid ]['status'] = 'F'
     
    913916                    debug_msg( 1, 'job %s appears to have finished' %jobid )
    914917
     918                    jobs_finished.append( jobid )
     919
    915920                    if not jobid in self.jobs_to_store:
    916921                        self.jobs_to_store.append( jobid )
     
    919924
    920925            elif self.jobAttrsSaved.has_key( jobid ):
     926
     927                # This should pretty much never happen, but hey let's be careful
     928                # Perhaps if someone altered their job while in queue with qalter
    921929
    922930                if self.jobinfoChanged( jobid, jobinfo ):
     
    949957                self.ds.storeJobInfo( jobid, self.jobAttrs[ jobid ] )
    950958
    951                 self.jobAttrsSaved[ jobid ] = self.jobAttrs[ jobid ]
     959                if not jobid in jobs_finished:
     960
     961                    self.jobAttrsSaved[ jobid ] = self.jobAttrs[ jobid ]
     962
     963                elif self.jobAttrsSaved.has_key( jobid ):
     964
     965                    del self.jobAttrsSaved[ jobid ]
    952966
    953967                if self.jobAttrs[ jobid ]['status'] == 'F':
     
    961975
    962976        self.jobs_processed = [ ]
     977
     978        # TODO: once in while check database AND self.jobAttrsSaved for stale jobs
    963979
    964980    def setJobAttrs( self, old, new ):
Note: See TracChangeset for help on using the changeset viewer.