Changeset 39 for trunk/daemon/togad.py


Ignore:
Timestamp:
04/05/05 10:08:24 (18 years ago)
Author:
bastiaans
Message:

daemon/togad.py:

Changed threading debug msg'es to be more understandable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/togad.py

    r38 r39  
    307307                                #
    308308                                xmlthread = threading.Thread( None, self.processXML, 'xmlthread' )
    309                                 debug_msg( 8, self.printTime() + ' - mainthread() - xmlthread() started' )
    310309                                xmlthread.start()
    311310
     
    316315                                #
    317316                                storethread = threading.Thread( None, self.storeMetrics, 'storethread' )
    318                                 debug_msg( 8, self.printTime() + ' - mainthread() - storethread() started' )
    319317                                storethread.start()
    320318               
     
    325323                "Store metrics retained in memory to disk"
    326324
     325                debug_msg( 8, self.printTime() + ' - storethread(): started.' )
     326
    327327                # Store metrics somewhere between every 60 and 180 seconds
    328328                #
    329329                STORE_INTERVAL = random.randint( 60, 180 )
    330330
    331                 debug_msg( 8, self.printTime() + ' - storethread() - storemetricthread() started: Storing data..' )
    332 
    333                 # threaded call to: self.myHandler.storeMetrics()
    334                 #
    335                 storethread = threading.Thread( None, self.myHandler.storeMetrics(), 'storemetricthread' )
     331                storethread = threading.Thread( None, self.storeThread, 'storemetricthread' )
    336332                storethread.start()
    337333
    338                 debug_msg( 8, self.printTime() + ' - storethread() - Sleeping.. (%ss)' %STORE_INTERVAL )
     334                debug_msg( 8, self.printTime() + ' - storethread(): Sleeping.. (%ss)' %STORE_INTERVAL )
    339335                time.sleep( STORE_INTERVAL )
    340                 debug_msg( 8, self.printTime() + ' - storethread() - Done sleeping.' )
     336                debug_msg( 8, self.printTime() + ' - storethread(): Done sleeping.' )
    341337
    342338                if storethread.isAlive():
    343339
    344                         debug_msg( 8, self.printTime() + ' - storethread() - storemetricthread() still running, waiting to finish..' )
    345                         parsethread.join( 180 ) # Maximum time is 3 minutes for storing thread to finish - more then enough
    346 
    347                 debug_msg( 8, self.printTime() + ' - storethread() - storemetricthread() finished.' )
    348 
    349                 debug_msg( 8, self.printTime() + ' - storethread() finished' )
     340                        debug_msg( 8, self.printTime() + ' - storethread(): storemetricthread() still running, waiting to finish..' )
     341                        parsethread.join( 180 ) # Maximum time is for storing thread to finish
     342                        debug_msg( 8, self.printTime() + ' - storethread(): Done waiting.' )
     343
     344                debug_msg( 8, self.printTime() + ' - storethread(): finished.' )
    350345
    351346                return 0
     347
     348        def storeThread( self ):
     349
     350                debug_msg( 8, self.printTime() + ' - storemetricthread(): started.' )
     351                debug_msg( 8, self.printTime() + ' - storemetricthread(): Storing data..' )
     352                ret = self.myHandler.storeMetrics()
     353                debug_msg( 8, self.printTime() + ' - storemetricthread(): Done storing.' )
     354                debug_msg( 8, self.printTime() + ' - storemetricthread(): finished.' )
     355               
     356                return ret
    352357
    353358        def processXML( self ):
    354359                "Process XML"
    355360
    356                 debug_msg( 8, self.printTime() + ' - xmlthread() - parsethread() started: Parsing..' )
    357 
    358                 # threaded call to: self.myParser.parse( self.myXMLGatherer.getFileObject() )
    359                 #
    360                 parsethread = threading.Thread( None, self.myParser.parse, 'parsethread', [ self.myXMLGatherer.getFileObject() ] )
     361                debug_msg( 8, self.printTime() + ' - xmlthread(): started.' )
     362
     363                parsethread = threading.Thread( None, self.parseThread, 'parsethread' )
    361364                parsethread.start()
    362365
    363                 debug_msg( 8, self.printTime() + ' - xmlthread() - Sleeping.. (%ss)' %self.config.getLowestInterval() )
     366                debug_msg( 8, self.printTime() + ' - xmlthread(): Sleeping.. (%ss)' %self.config.getLowestInterval() )
    364367                time.sleep( float( self.config.getLowestInterval() ) ) 
    365                 debug_msg( 8, self.printTime() + ' - xmlthread() - Done sleeping.' )
     368                debug_msg( 8, self.printTime() + ' - xmlthread(): Done sleeping.' )
    366369
    367370                if parsethread.isAlive():
    368371
    369                         debug_msg( 8, self.printTime() + ' - xmlthread() - parsethread() still running, waiting to finish..' )
    370                         parsethread.join( 180 ) # Maximum time is 3 minutes for XML thread to finish - more then enough
    371 
    372                 debug_msg( 8, self.printTime() + ' - xmlthread() - parsethread() finished.' )
    373 
    374                 debug_msg( 8, self.printTime() + ' - xmlthread() finished.' )
     372                        debug_msg( 8, self.printTime() + ' - xmlthread(): parsethread() still running, waiting to finish..' )
     373                        parsethread.join( 60 ) # Maximum time for XML thread to finish
     374                        debug_msg( 8, self.printTime() + ' - xmlthread(): Done waiting.' )
     375
     376                debug_msg( 8, self.printTime() + ' - xmlthread(): finished.' )
    375377
    376378                return 0
     379
     380        def parseThread( self ):
     381
     382                debug_msg( 8, self.printTime() + ' - parsethread(): started.' )
     383                debug_msg( 8, self.printTime() + ' - parsethread(): Parsing XML..' )
     384                ret = self.myParser.parse( self.myXMLGatherer.getFileObject() )
     385                debug_msg( 8, self.printTime() + ' - parsethread(): Done parsing.' )
     386                debug_msg( 8, self.printTime() + ' - parsethread(): finished.' )
     387
     388                return ret
    377389
    378390class GangliaConfigParser:
Note: See TracChangeset for help on using the changeset viewer.