From 943907790ce804df7ba94f523115099bc961a2b4 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 16 Jan 2013 15:51:47 +0000 Subject: ThreadGroup remove unused name parameters Thread/ThreadGroup constructors take a name parameter which is never used, so we can simplify things a bit by removing it. If anything is referencing the internal self.name it should be using its own name->threadgroup mapping (e.g via a dict or similar container class) Change-Id: I6877a2fcee60ce9fc087d38aa492d7c9d50ce97e Signed-off-by: Steven Hardy --- openstack/common/service.py | 4 ++-- openstack/common/threadgroup.py | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'openstack') diff --git a/openstack/common/service.py b/openstack/common/service.py index 6b180aa..48aeb9d 100644 --- a/openstack/common/service.py +++ b/openstack/common/service.py @@ -51,7 +51,7 @@ class Launcher(object): :returns: None """ - self._services = threadgroup.ThreadGroup('launcher') + self._services = threadgroup.ThreadGroup() eventlet_backdoor.initialize_if_enabled() @staticmethod @@ -310,7 +310,7 @@ class Service(object): """Service object for binaries running on hosts.""" def __init__(self, threads=1000): - self.tg = threadgroup.ThreadGroup('service', threads) + self.tg = threadgroup.ThreadGroup(threads) def start(self): pass diff --git a/openstack/common/threadgroup.py b/openstack/common/threadgroup.py index 1f80fef..a87497f 100644 --- a/openstack/common/threadgroup.py +++ b/openstack/common/threadgroup.py @@ -38,8 +38,7 @@ class Thread(object): :class:`ThreadGroup`. The Thread will notify the :class:`ThreadGroup` when it has done so it can be removed from the threads list. """ - def __init__(self, name, thread, group): - self.name = name + def __init__(self, thread, group): self.thread = thread self.thread.link(_thread_done, group=group, thread=self) @@ -57,8 +56,7 @@ class ThreadGroup(object): when need be). * provide an easy API to add timers. """ - def __init__(self, name, thread_pool_size=10): - self.name = name + def __init__(self, thread_pool_size=10): self.pool = greenpool.GreenPool(thread_pool_size) self.threads = [] self.timers = [] @@ -72,7 +70,7 @@ class ThreadGroup(object): def add_thread(self, callback, *args, **kwargs): gt = self.pool.spawn(callback, *args, **kwargs) - th = Thread(callback.__name__, gt, self) + th = Thread(gt, self) self.threads.append(th) def thread_done(self, thread): -- cgit