예제 #1
0
class WorkerPool(object):
    def __init__(self, num_threads=None):
        if num_threads is None:
            num_threads = multiprocessing.cpu_count()
        self.tasks = Queue(num_threads)
        for _ in range(num_threads):
            Worker(self.tasks)

    def add_task(self, func, *args, **kargs):
        self.tasks.put((func, args, kargs))

    def wait_for_completion(self):
        self.tasks.join()
예제 #2
0
class WorkerPool(object):

    def __init__(self, num_threads=None):
        if num_threads is None:
            num_threads = multiprocessing.cpu_count()
        self.tasks = Queue(num_threads)
        for _ in range(num_threads):
            Worker(self.tasks)

    def add_task(self, func, *args, **kargs):
        self.tasks.put((func, args, kargs))

    def wait_for_completion(self):
        self.tasks.join()
예제 #3
0
 def __init__(self, num_threads=None):
     if num_threads is None:
         num_threads = multiprocessing.cpu_count()
     self.tasks = Queue(num_threads)
     for _ in range(num_threads):
         Worker(self.tasks)
예제 #4
0
 def __init__(self, num_threads=None):
     if num_threads is None:
         num_threads = multiprocessing.cpu_count()
     self.tasks = Queue(num_threads)
     for _ in range(num_threads):
         Worker(self.tasks)