Detect exception in debugger session, set Task to Failed

This commit is contained in:
allegroai 2020-04-16 16:43:10 +03:00
parent 4eaa77dbdb
commit 215aa32239

View File

@ -1853,14 +1853,22 @@ class Task(_Task):
# check if we crashed, ot the signal is not interrupt (manual break) # check if we crashed, ot the signal is not interrupt (manual break)
task_status = ('stopped', ) task_status = ('stopped', )
if self.__exit_hook: if self.__exit_hook:
if (self.__exit_hook.exception and not isinstance(self.__exit_hook.exception, KeyboardInterrupt)) \ is_exception = self.__exit_hook.exception
# check if we are running inside a debugger
if not is_exception and sys.modules.get('pydevd'):
try:
is_exception = sys.last_type
except:
pass
if (is_exception and not isinstance(self.__exit_hook.exception, KeyboardInterrupt)) \
or (not self.__exit_hook.remote_user_aborted and self.__exit_hook.signal not in (None, 2)): or (not self.__exit_hook.remote_user_aborted and self.__exit_hook.signal not in (None, 2)):
task_status = ('failed', 'Exception') task_status = ('failed', 'Exception')
wait_for_uploads = False wait_for_uploads = False
else: else:
wait_for_uploads = (self.__exit_hook.remote_user_aborted or self.__exit_hook.signal is None) wait_for_uploads = (self.__exit_hook.remote_user_aborted or self.__exit_hook.signal is None)
if not self.__exit_hook.remote_user_aborted and self.__exit_hook.signal is None and \ if not self.__exit_hook.remote_user_aborted and self.__exit_hook.signal is None and \
not self.__exit_hook.exception: not is_exception:
task_status = ('completed', ) task_status = ('completed', )
else: else:
task_status = ('stopped', ) task_status = ('stopped', )