Пример #1
0
 def terminate(self):
     """
     Sets the terminate event on the scheduled executor
     :return:
     """
     with rLock():
         self.__terminated = True
         self.__thread_pool.terminate()
Пример #2
0
 def terminate(self):
     """
     Sets the terminate event on the scheduled executor
     :return:
     """
     with rLock():
         self.__terminated = True
         self.__thread_pool.terminate()
Пример #3
0
 def _create_worker_threads(self):
     with rLock():
         while len(self.__worker_threads) < self.__pool_size:
             thread_name = "%s-%s" % (self.__pool_name, (len(self.__worker_threads) + 1))
             worker_thread = _WorkerThread(self.__task_queue, thread_name, self.__polling_timeout)
             worker_thread.setDaemon(self.__daemon)
             worker_thread.start()
             self.__worker_threads.append(worker_thread)
Пример #4
0
    def get_pool_size(self):
        """
        Returns the size of the thread pool.

        :return: The size of the thread pool
        :rtype: int
        """
        with rLock():
            return self.__pool_size
Пример #5
0
    def get_pool_size(self):
        """
        Returns the size of the thread pool.

        :return: The size of the thread pool
        :rtype: int
        """
        with rLock():
            return self.__pool_size
Пример #6
0
 def _create_worker_threads(self):
     with rLock():
         while len(self.__worker_threads) < self.__pool_size:
             thread_name = "%s-%s" % (self.__pool_name,
                                      (len(self.__worker_threads) + 1))
             worker_thread = _WorkerThread(self.__task_queue, thread_name,
                                           self.__polling_timeout)
             worker_thread.setDaemon(self.__daemon)
             worker_thread.start()
             self.__worker_threads.append(worker_thread)
Пример #7
0
 def terminate(self):
     """
     Waits for the task queue to finish and sends the terminate event for all the worker threads.
     :return:
     """
     with rLock():
         log.debug("Waiting until all the tasks are done")
         self.__task_queue.join()
         log.debug("Sending termination signal for the worker threads")
         for worker_thread in self.__worker_threads:
             worker_thread.terminate()
Пример #8
0
 def terminate(self):
     """
     Waits for the task queue to finish and sends the terminate event for all the worker threads.
     :return:
     """
     with rLock():
         log.debug("Waiting until all the tasks are done")
         self.__task_queue.join()
         log.debug("Sending termination signal for the worker threads")
         for worker_thread in self.__worker_threads:
             worker_thread.terminate()
Пример #9
0
    def run(self):
        # start job
        while not self.__terminated:
            start_time = time.time()
            with rLock():
                # sleep for the required duration if lock acquisition took time
                if not self.__terminated:
                    lock_end_time = time.time()
                    remaining_wait_time = self.__delay - (lock_end_time - start_time)
                    if remaining_wait_time > 0.0:
                        time.sleep(remaining_wait_time)

                    if not self.__terminated:
                        self.__thread_pool.enqueue(self.__task)
Пример #10
0
    def run(self):
        # start job
        while not self.__terminated:
            start_time = time.time()
            with rLock():
                # sleep for the required duration if lock acquisition took time
                if not self.__terminated:
                    lock_end_time = time.time()
                    remaining_wait_time = self.__delay - (lock_end_time -
                                                          start_time)
                    if remaining_wait_time > 0.0:
                        time.sleep(remaining_wait_time)

                    if not self.__terminated:
                        self.__thread_pool.enqueue(self.__task)
	
        	            break



	            self.pbar.finish()

        

if __name__=="__main__":

    with term.fullscreen():

            condition = threading.Condition()

            rlock=threading.rLock()    

            threads = []

            x = 0

            y = 10



            mainThread = MyThread((x,y),condition,rlock)

            y+=1