浏览代码

Bug fix with monitoring

steve 8 年之前
父节点
当前提交
a1acc24da4
共有 1 个文件被更改,包括 18 次插入16 次删除
  1. 18 16
      src/utils/workers.py

+ 18 - 16
src/utils/workers.py

@@ -1,15 +1,17 @@
-import multiprocessing
+#import multiprocessing
+from threading import Thread, Lock
 from utils import transport
 from utils import transport
 import time
 import time
 import monitor
 import monitor
 import sys
 import sys
+import os
 """
 """
 	This class is intended to collect data given a configuration
 	This class is intended to collect data given a configuration
 
 
 """
 """
-class Top(multiprocessing.Process):
+class Top(Thread):
 	def __init__(self,_config,lock):
 	def __init__(self,_config,lock):
-		multiprocessing.Process.__init__(self)
+		Thread.__init__(self)
 		self.lock = lock
 		self.lock = lock
 		self.reader_class	= _config['store']['class']['read']
 		self.reader_class	= _config['store']['class']['read']
 		self.write_class	= _config['store']['class']['write']
 		self.write_class	= _config['store']['class']['write']
@@ -18,12 +20,7 @@ class Top(multiprocessing.Process):
 		
 		
 		self.name = 'Zulu-Top'
 		self.name = 'Zulu-Top'
 		self.quit = False
 		self.quit = False
-		print sys.argv
-		sys.argv[0] = self.name
-		print sys.argv
-		# multiprocessing.current_process().name = 'Zulu-Top'
-		self.exit = multiprocessing.Event()
-		
+
 		
 		
 		className = ''.join(['monitor.',_config['monitor']['processes']['class'],'()'])
 		className = ''.join(['monitor.',_config['monitor']['processes']['class'],'()'])
 		self.handler = eval(className)
 		self.handler = eval(className)
@@ -35,24 +32,29 @@ class Top(multiprocessing.Process):
 			for label in self.config :
 			for label in self.config :
 				self.lock.acquire()
 				self.lock.acquire()
 				gwriter = self.factory.instance(type=self.write_class,args=self.rw_args)
 				gwriter = self.factory.instance(type=self.write_class,args=self.rw_args)
-				for app in self.config[label] :
-					self.handler.init(app)	
-					r = self.handler.composite()
-					gwriter.write(label=label,row=r)
-					time.sleep(5)
+				apps = self.config[label]
+				self.handler.init(apps)	
+				r = self.handler.composite()
+				gwriter.write(label=label,row=r)
+				time.sleep(5)
 				self.lock.release()
 				self.lock.release()
+			if 'MONITOR_CONFIG_PATH' in os.environ:
+				#
+				# This suggests we are in development mode
+				#
+				break
 			ELLAPSED_TIME = 60*30
 			ELLAPSED_TIME = 60*30
 			time.sleep(ELLAPSED_TIME)
 			time.sleep(ELLAPSED_TIME)
 		print "Exiting ",self.name
 		print "Exiting ",self.name
 				
 				
-class Learner(multiprocessing.Process) :
+class Learner(Thread) :
 	
 	
 	"""
 	"""
 		This function expects paltform config (store,learner)
 		This function expects paltform config (store,learner)
 		It will leverage store and learner in order to operate
 		It will leverage store and learner in order to operate
 	"""
 	"""
 	def __init__(self,config,lock):
 	def __init__(self,config,lock):
-		multiprocessing.Process.__init__(self)
+		Thread.__init__(self)
 		self.name='Zulu-Learner'
 		self.name='Zulu-Learner'
 		self.lock = lock
 		self.lock = lock
 		self.reader_class	= config['store']['class']['read']
 		self.reader_class	= config['store']['class']['read']