diff options
author | Ross Burton <ross@burtonini.com> | 2021-11-24 17:15:27 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-11-25 21:55:10 +0000 |
commit | 1fb99950a2725e6720fe22c92ee81ba5a67c400c (patch) | |
tree | e2f7e1e66937e627e9be92ca5390332aa75d4546 /meta/lib/oe | |
parent | cd91af372f85ff293ee1498f9fee40cb17fbcb4b (diff) | |
download | poky-1fb99950a2725e6720fe22c92ee81ba5a67c400c.tar.gz |
oe/utils: allow naming threads in ThreadedPool
When looking at logs involving thread pools it is useful if the threads
can be named.
(From OE-Core rev: 18342945b021608794d83ecf567afd43f4379b24)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r-- | meta/lib/oe/utils.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py index cf65639647..7982b2b511 100644 --- a/meta/lib/oe/utils.py +++ b/meta/lib/oe/utils.py | |||
@@ -483,8 +483,8 @@ from threading import Thread | |||
483 | 483 | ||
484 | class ThreadedWorker(Thread): | 484 | class ThreadedWorker(Thread): |
485 | """Thread executing tasks from a given tasks queue""" | 485 | """Thread executing tasks from a given tasks queue""" |
486 | def __init__(self, tasks, worker_init, worker_end): | 486 | def __init__(self, tasks, worker_init, worker_end, name=None): |
487 | Thread.__init__(self) | 487 | Thread.__init__(self, name=name) |
488 | self.tasks = tasks | 488 | self.tasks = tasks |
489 | self.daemon = True | 489 | self.daemon = True |
490 | 490 | ||
@@ -515,13 +515,12 @@ class ThreadedWorker(Thread): | |||
515 | 515 | ||
516 | class ThreadedPool: | 516 | class ThreadedPool: |
517 | """Pool of threads consuming tasks from a queue""" | 517 | """Pool of threads consuming tasks from a queue""" |
518 | def __init__(self, num_workers, num_tasks, worker_init=None, | 518 | def __init__(self, num_workers, num_tasks, worker_init=None, worker_end=None, name="ThreadedPool-"): |
519 | worker_end=None): | ||
520 | self.tasks = Queue(num_tasks) | 519 | self.tasks = Queue(num_tasks) |
521 | self.workers = [] | 520 | self.workers = [] |
522 | 521 | ||
523 | for _ in range(num_workers): | 522 | for i in range(num_workers): |
524 | worker = ThreadedWorker(self.tasks, worker_init, worker_end) | 523 | worker = ThreadedWorker(self.tasks, worker_init, worker_end, name=name + str(i)) |
525 | self.workers.append(worker) | 524 | self.workers.append(worker) |
526 | 525 | ||
527 | def start(self): | 526 | def start(self): |