diff options
author | Csaba Henk <csaba@gluster.com> | 2011-04-13 01:46:05 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-04-13 04:43:06 -0700 |
commit | e5c38128fa76b3e11047d49448aab77d3a551804 (patch) | |
tree | 749ec60fc891e1430a9d7bac112a9d660a4bc106 /xlators/features/marker/utils/syncdaemon/syncdutils.py | |
parent | 13d1856a40122008dee35a96771f832945c220f8 (diff) |
syncdaemon: force termination for unhandled exception in any thread
Signed-off-by: Csaba Henk <csaba@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2736 (gsyncd hangs if crash occurs in the non-main thread)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2736
Diffstat (limited to 'xlators/features/marker/utils/syncdaemon/syncdutils.py')
-rw-r--r-- | xlators/features/marker/utils/syncdaemon/syncdutils.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/syncdutils.py b/xlators/features/marker/utils/syncdaemon/syncdutils.py index d3ab2f345..56bc515d4 100644 --- a/xlators/features/marker/utils/syncdaemon/syncdutils.py +++ b/xlators/features/marker/utils/syncdaemon/syncdutils.py @@ -1,5 +1,8 @@ import os import fcntl +from threading import Thread as baseThread +from signal import SIGTERM + try: # py 3 from urllib import parse as urllib @@ -49,3 +52,20 @@ class FreeObject(object): def __init__(self, **kw): for k,v in kw.iteritems(): setattr(self, k, v) + +class Thread(baseThread): + + def __init__(self, *a, **kw): + tf = kw.get('target') + if tf: + def twrap(*aa): + try: + tf(*aa) + except: + try: + raise + finally: + os.kill(os.getpid(), SIGTERM) + kw['target'] = twrap + baseThread.__init__(self, *a, **kw) + self.setDaemon(True) |