예제 #1
0
파일: task.py 프로젝트: lixiaojun/cyepusher
 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
     
예제 #2
0
파일: task.py 프로젝트: lixiaojun/cyepusher
 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
예제 #3
0
 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.'
예제 #4
0
    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))
예제 #5
0
 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()
예제 #6
0
 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()
예제 #7
0
 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.'
예제 #8
0
    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))
예제 #9
0
파일: task.py 프로젝트: lixiaojun/cyepusher
 def __call__(self):
     say = 'Hello, %s' % self.name
     print say
     logger.info('Task say: %s' % say)
예제 #10
0
파일: task.py 프로젝트: lixiaojun/cyepusher
 def __call__(self):
     say = 'Hello, %s' % self.name
     print say
     logger.info('Task say: %s' % say)
예제 #11
0
 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)
예제 #12
0
 def __init__(self,pool,tasks):
     super(ThreadPoolManager,self).__init__()
    
     self.pool = pool
     self.tasks = tasks
     logger.info('ThreadPool Manager run.')
예제 #13
0
 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)
예제 #14
0
    def __init__(self, pool, tasks):
        super(ThreadPoolManager, self).__init__()

        self.pool = pool
        self.tasks = tasks
        logger.info('ThreadPool Manager run.')