def __call__(self): info = 'Fetch cye data by id = 1' print info logger.info('Task: '+info) d = cyeTbReflector.loadObjectsFrom('cye_tb', whereClause=[("id", reflector.EQUAL, self.id)]) print d
def __call__(self): info = 'Fetch cye data by id = 1' print info logger.info('Task: ' + info) d = cyeTbReflector.loadObjectsFrom('cye_tb', whereClause=[("id", reflector.EQUAL, self.id)]) print d
def addTask(self,task): try: self.tasks.put(task, 0) logger.info('New task join in, Current length of Queue [%d]' % self.tasks.qsize()) print 'New task join in, Current length of Queue [%d]' % self.tasks.qsize() except: logger.error('The task queue is full.') raise Exception,'This queue is full.'
def initPool(self,pool_min_size = 5,pool_max_size = 10): self.pool_min_size = pool_min_size self.pool_max_size = pool_max_size self.pool = [] for i in range(self.pool_min_size): t = TaskThread() self.pool.append(t) logger.info('Initialize Thread Pool. min_size = %d, max_size = %d' % (self.pool_min_size, self.pool_max_size))
def run(self): while self.isActive(): try: logger.info('[%s] is working ' % self.getName()) print '%s is working' % self.getName() self.task() except: pass finally: self.wait()
def addTask(self, task): try: self.tasks.put(task, 0) logger.info('New task join in, Current length of Queue [%d]' % self.tasks.qsize()) print 'New task join in, Current length of Queue [%d]' % self.tasks.qsize( ) except: logger.error('The task queue is full.') raise Exception, 'This queue is full.'
def initPool(self, pool_min_size=5, pool_max_size=10): self.pool_min_size = pool_min_size self.pool_max_size = pool_max_size self.pool = [] for i in range(self.pool_min_size): t = TaskThread() self.pool.append(t) logger.info('Initialize Thread Pool. min_size = %d, max_size = %d' % (self.pool_min_size, self.pool_max_size))
def __call__(self): say = 'Hello, %s' % self.name print say logger.info('Task say: %s' % say)
def initQueue(self,task_queue_size = 100, timeout=5): self.tasks = Queue.Queue(task_queue_size) self.timeout = timeout logger.info('Initislize Task Queue. size is (%d)' % task_queue_size)
def __init__(self,pool,tasks): super(ThreadPoolManager,self).__init__() self.pool = pool self.tasks = tasks logger.info('ThreadPool Manager run.')
def initQueue(self, task_queue_size=100, timeout=5): self.tasks = Queue.Queue(task_queue_size) self.timeout = timeout logger.info('Initislize Task Queue. size is (%d)' % task_queue_size)
def __init__(self, pool, tasks): super(ThreadPoolManager, self).__init__() self.pool = pool self.tasks = tasks logger.info('ThreadPool Manager run.')