diff options
author | Angus Salkeld <asalkeld@redhat.com> | 2012-11-01 10:29:42 +1100 |
---|---|---|
committer | Angus Salkeld <asalkeld@redhat.com> | 2012-11-01 17:05:32 +1100 |
commit | 5ea881a31173380e10ffdd6b05c02f92d9177f04 (patch) | |
tree | ea2e194d6fa99bf5ad800f53acf111a7cfa023ea /openstack/common/threadgroup.py | |
parent | 3e04c41c96fbf5916ff5ab8c3a8bfec5021f6b04 (diff) | |
download | oslo-5ea881a31173380e10ffdd6b05c02f92d9177f04.tar.gz oslo-5ea881a31173380e10ffdd6b05c02f92d9177f04.tar.xz oslo-5ea881a31173380e10ffdd6b05c02f92d9177f04.zip |
Don't log exceptions for GreenletExit and thread_done
1) Greenletexit is normal so don't log it.
2) logging in a linked callback is just asking for problems.
(we don't want to cause a context switch in this callback).
Change-Id: Ia9bb1cabc65a742fc49beb379548eb680b326e58
Diffstat (limited to 'openstack/common/threadgroup.py')
-rw-r--r-- | openstack/common/threadgroup.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/openstack/common/threadgroup.py b/openstack/common/threadgroup.py index ebc066a..9d2f0b6 100644 --- a/openstack/common/threadgroup.py +++ b/openstack/common/threadgroup.py @@ -13,10 +13,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import os -import sys -from eventlet import event +from eventlet import greenlet from eventlet import greenpool from eventlet import greenthread @@ -29,7 +27,11 @@ LOG = logging.getLogger(__name__) def _thread_done(gt, *args, **kwargs): - args[0].thread_done(args[1]) + ''' + Callback function to be passed to GreenThread.link() when we spawn() + Calls the ThreadGroup to notify if. + ''' + kwargs['group'].thread_done(kwargs['thread']) class Thread(object): @@ -42,7 +44,7 @@ class Thread(object): def __init__(self, name, thread, group): self.name = name self.thread = thread - self.thread.link(_thread_done, group, self) + self.thread.link(_thread_done, group=group, thread=self) def stop(self): self.thread.cancel() @@ -77,12 +79,7 @@ class ThreadGroup(): self.threads.append(th) def thread_done(self, thread): - try: - thread.wait() - except Exception as ex: - LOG.exception(ex) - finally: - self.threads.remove(thread) + self.threads.remove(thread) def stop(self): current = greenthread.getcurrent() @@ -106,6 +103,8 @@ class ThreadGroup(): for x in self.timers: try: x.wait() + except greenlet.GreenletExit: + pass except Exception as ex: LOG.exception(ex) current = greenthread.getcurrent() @@ -114,5 +113,7 @@ class ThreadGroup(): continue try: x.wait() + except greenlet.GreenletExit: + pass except Exception as ex: LOG.exception(ex) |