mirror of https://gitlab.com/bashrc2/epicyon
Exceptions on threads
parent
91073aca1b
commit
cb0f95c62b
24
threads.py
24
threads.py
|
@ -13,19 +13,43 @@ import time
|
||||||
|
|
||||||
class threadWithTrace(threading.Thread):
|
class threadWithTrace(threading.Thread):
|
||||||
def __init__(self, *args, **keywords):
|
def __init__(self, *args, **keywords):
|
||||||
|
tries=0
|
||||||
|
while tries<3:
|
||||||
|
try:
|
||||||
self._args, self._keywords = args, keywords
|
self._args, self._keywords = args, keywords
|
||||||
threading.Thread.__init__(self, *self._args, **self._keywords)
|
threading.Thread.__init__(self, *self._args, **self._keywords)
|
||||||
self.killed = False
|
self.killed = False
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
print('ERROR: threads.py/__init__ failed - '+str(e))
|
||||||
|
time.sleep(1)
|
||||||
|
tries+=1
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
tries=0
|
||||||
|
while tries<3:
|
||||||
|
try:
|
||||||
self.__run_backup = self.run
|
self.__run_backup = self.run
|
||||||
self.run = self.__run
|
self.run = self.__run
|
||||||
threading.Thread.start(self)
|
threading.Thread.start(self)
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
print('ERROR: threads.py/start failed - '+str(e))
|
||||||
|
time.sleep(1)
|
||||||
|
tries+=1
|
||||||
|
|
||||||
def __run(self):
|
def __run(self):
|
||||||
|
tries=0
|
||||||
|
while tries<3:
|
||||||
|
try:
|
||||||
sys.settrace(self.globaltrace)
|
sys.settrace(self.globaltrace)
|
||||||
self.__run_backup()
|
self.__run_backup()
|
||||||
self.run = self.__run_backup
|
self.run = self.__run_backup
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
print('ERROR: threads.py/__run failed - '+str(e))
|
||||||
|
time.sleep(1)
|
||||||
|
tries+=1
|
||||||
|
|
||||||
def globaltrace(self, frame, event, arg):
|
def globaltrace(self, frame, event, arg):
|
||||||
if event == 'call':
|
if event == 'call':
|
||||||
|
|
Loading…
Reference in New Issue