def dequeue_new_jobs(self):	    
        """Subscribe to new jobs from Redis. """ 
        job_counter = 0               
        while self.is_stopped(self.base_url)==False:     
            if len(self.freenodes)==0:
                time.sleep(3)
                continue
            logging.debug("Dequeue sub-job from: " + self.base_url)       
            job_url=self.coordination.dequeue_job(self.base_url)
            if job_url==None:
                time.sleep(3)
                continue
            if job_url=="STOP":
                break
            
            job_counter = job_counter + 1            
            if (job_counter % (THREAD_POOL_SIZE))==0: # ensure that threadpool is not too overloaded
                self.threadpool.wait()
            
            request = WorkRequest(self.start_new_job_in_thread, [job_url])
            self.threadpool.putRequest(request)
            
        # wait for termination of Worker Threads
        self.threadpool.wait()   
        logging.debug("Terminating Agent - Dequeue Sub-Jobs Thread")   
       
    #def poll_jobs(self):       
    #    self.threadpool.wait()
    #    new_jobs=self.redis.keys(self.base_url+":*")   
    #    logging.debug("All jobs:" + str(new_jobs))
    #    for i in new_jobs:            
    #        request = WorkRequest(self.start_new_job_in_thread, [str(i)])
    #        logging.debug("WorkRequest: " + str(request))
    #        self.threadpool.putRequest(request)
dataset/ETHPy150Open saga-project/BigJob/bigjob/bigjob_agent_condor.py/bigjob_agent.dequeue_new_jobs/original