summaryrefslogtreecommitdiffstats
path: root/xlators/features/marker/utils/syncdaemon/syncdutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/features/marker/utils/syncdaemon/syncdutils.py')
-rw-r--r--xlators/features/marker/utils/syncdaemon/syncdutils.py20
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)