Example #1
0
		self.worker_control.release()


if __name__ == '__main__':

	print "PROCESSER RUNNING"
	print "#CPU COUNT : %s" % psutil.cpu_count()

	worker_control = Semaphore(psutil.cpu_count())

	while True:

		if worker_control.acquire(False):

			db.reconnect()

			t = db.table("tasks").where("processing_status","=",0).first()

			if t is not None:

				task_id = t.task_id

				db.table("tasks").where("task_id","like",task_id).update({'processing_status': 1})

				num_tasks = db.table("tasks").where("task_id","like",task_id).count()
				print num_tasks

				if num_tasks > 1:
					w = BatchWorker(task_id,worker_control)
					w.start()