(self, num_threads=None, queue_size=0)
| 444 | """ |
| 445 | |
| 446 | def __init__(self, num_threads=None, queue_size=0): |
| 447 | # if no count passed, default to number of CPUs |
| 448 | if num_threads is None: |
| 449 | num_threads = multiprocessing.cpu_count() |
| 450 | self.num_threads = num_threads |
| 451 | |
| 452 | # create a task queue of queue_size |
| 453 | self._job_queue = queue.Queue(queue_size) |
| 454 | |
| 455 | self._workers = [] |
| 456 | |
| 457 | # create worker threads |
| 458 | for _ in range(num_threads): |
| 459 | thread = threading.Thread(target=self._thread_target) |
| 460 | thread.daemon = True |
| 461 | thread.start() |
| 462 | self._workers.append(thread) |
| 463 | |
| 464 | # intentionally not called "apply_async" since we aren't keeping track of |
| 465 | # the return at all, if we want to make this API compatible with multiprocessing |
no test coverage detected