Пример #1
0
	def newworker(self,casename,config):
		self.newlock.acquire()
		if self.stopflag!=True:
			q=Queue()
			dataq=Queue()
			name=(casename+"__"+time.strftime("%Y-%m-%d__%H.%M.%S", time.localtime()).replace(':','.')).decode('gbk').encode('utf8')
			self.workerinfo[name]=[so.workerstatus[0],0,0,'','','',{}]
			if self.pushqueuecount<cp.maxpush:
				#_dict=['planname',(name,runmanagerinstance_self,casename.config.q)]
				_dict=[self.planhandler.name,(name,self,casename,config,q,dataq)]
				runqueue.push(_dict,self)
				so.runmanagerlog.debug('push case:'+casename+' in config:'+str(config)+' to manager runlist,planname:'+self.planhandler.name)
			else:
				self.waitingqueue.append([name,casename,config,q,dataq])  #存入等待队列,不会进行push
				so.runmanagerlog.debug('push case:'+casename+' in config:'+str(config)+' to manager waitlist,planname:'+self.planhandler.name)
				self.workerinfo[name]=[so.workerstatus[4],0,0,'','','',{}]
			self.newlock.release()
			time.sleep(1)	#单个plan最短push间隔至少1秒
			return name
		else:
			newlock.release()
			return None
Пример #2
0
			self.webdrivercollection.pop(name)
		except Exception, e:
			pass
		if self.stopflag!=True:
			if self.workerinfo[name][0]!=so.workerstatus[3]:
				self.workerinfo[name][0]=so.workerstatus[2]
			self.setworkerinfo(name,res)
			if self.finishedworkercount==len(self.planhandler.plancases) and self.stopflag!=True:
				self.planhandler.finishedtocall()
			self.pushqueuecount=self.pushqueuecount-1
			so.runmanagerlog.info('pushqueuecount -1,length:'+str(self.pushqueuecount)+' plan:'+str(self.planhandler.name))
			if len(self.waitingqueue)>0:
				try:
					case=self.waitingqueue.pop(0)
					_dict=[self.planhandler.name,(case[0],self,case[1],case[2],case[3])]
					runqueue.push(_dict)  #一个worker执行完毕后再push一个worker
					so.runmanagerlog.info('push another case to runqueue,case:'+str(case[0])+',plan:'+str(self.planhandler.name))
				except Exception,e:
					so.runmanagerlog.error('error occured during push a new case to runqueue,plan:'+str(self.planhandler.name))
		runqueue.runningqueuelength=runqueue.runningqueuelength-1
		so.runmanagerlog.info('runningqueuelength -1 ,length:'+str(runqueue.runningqueuelength)+' from plan:'+str(self.planhandler.name))


	def __getrunningdriver(self,name,queue):
		try:
			msg=queue.get(timeout=30)
			from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
			if isinstance(msg,RemoteWebDriver):
				self.webdrivercollection[name]=msg
			else:
				self.msgcontainer[name]=msg