Example #1
0
def simu(options):
	itera = 0
	
	#################################
	# Begin simu
	if(options.reset):
		if(not prims.initDb()):
			raise util.SimuException("Market is not opened")
			
	begin = util.getAvct(None)
	with util.DbConn(const) as dbcon:
		with util.DbCursor(dbcon) as cursor:
		
			util.writeMaxOptions(cursor,options)
			
			for user in util.nameUsers():
				prims.createUser(cursor,user)
				
			if(options.CHECKQUALITYOWNERSHIP):
				util.setQualityOwnership(cursor,True)
	
	##################################
	if((not scenarii.threadAllowed(options.scenario)) and options.threads>1):
		raise Exception("This scenario cannot be run in thread")
		
	_begin = util.now()
	if(options.threads==1):	
		user = util.nameUser(0)
		scenarii.simuInt((options,user))
	else:
		# run in theads		
		ts = []	
		for i in range(options.threads):
			user = util.nameUser(i)
			t = threa.ThreadWithArgs(func=scenarii.simuInt,args=(options,user),name=user)
			t.start()
			ts.append(t)
		for t in ts:
			t.join()
			
	itera = options.iteration * options.threads
	
	duree = util.duree(_begin,util.now())
	##################################
	# Terminate simu
	
	terminate(begin,duree,itera,options)
	return
Example #2
0
	def getDelay(self):
		if(self.start is None or self.stop is None):
			return 0.
		return util.duree(self.start,self.stop)