cocluto/ClusterController/JobsStateUpdater.py

36 lines
1012 B
Python
Raw Normal View History

import threading
import Util
import os
import traceback
import sys
import time
class JobsStateUpdater( threading.Thread ):
DELAY_BETWEEN_STATUS_CHECKS=10 # in seconds
def __init__( self, clusterStatus ):
threading.Thread.__init__(self)
self.m_clusterStatus = clusterStatus
self.m_bStop = False
def getName( self ):
return 'JobsStateUpdater'
def getGridEngine( self ):
return self.m_clusterStatus.getGridEngine()
def updateClusterStatus( self ):
#log('JobsStateUpdater::updateClusterStatus : start')
jobsState = self.getGridEngine().getCurrentJobsState()
# update the jobs in the cluster status
self.m_clusterStatus.onNewJobsState( jobsState )
#log('JobsStateUpdater::updateClusterStatus : end')
def run( self ):
try:
while not self.m_bStop :
self.updateClusterStatus()
time.sleep(JobsStateUpdater.DELAY_BETWEEN_STATUS_CHECKS)
except BaseException, exception: # catches all exceptions, including the ctrl+C (KeyboardInterrupt)
Util.onException(exception)