summaryrefslogtreecommitdiffstats
path: root/openstack
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-11-01 12:07:11 +0000
committerGerrit Code Review <review@openstack.org>2012-11-01 12:07:11 +0000
commit3d6c2368a5de16d875341426db8ddc9888213264 (patch)
tree4d4eaae7c011e4616aa51864ba5b7eba6f35f387 /openstack
parent00030ec28f496ec0bb23a0ab892cc6d4af9dcdac (diff)
parent5ea881a31173380e10ffdd6b05c02f92d9177f04 (diff)
downloadoslo-3d6c2368a5de16d875341426db8ddc9888213264.tar.gz
oslo-3d6c2368a5de16d875341426db8ddc9888213264.tar.xz
oslo-3d6c2368a5de16d875341426db8ddc9888213264.zip
Merge "Don't log exceptions for GreenletExit and thread_done"
Diffstat (limited to 'openstack')
-rw-r--r--openstack/common/threadgroup.py23
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)