def add_error_handling(run_job_func):
def wrap(*args, **kwargs):
try:
return run_job_func(*args, **kwargs)
# all keyboard interrupt during streaming will be caught and raised as JobInterruptedException
# anything here will be during upload or download, so we just abort
except KeyboardInterrupt as e:
print('\nJob aborted')
abort_and_print_credit()
# print('\nStreaming stopped, code is still running in the cloud')
# print('Your job hash is: %s' % settings.CURRENT_JOB_HASH)
except RequestFailedException as e:
print('Oops, something went wrong...')
print(e.error_msg)
print('Please try again later')
sys.tracebacklimit = 0
sys.exit()
# except JobInterruptedException as e:
# # extra newline incase no newline was printed
# # print('\nJob interrupted')
# # ans = input('Do you want to abort the job?\n')
# # if ans == 'yes':
# # abort_and_print_credit()
# # else:
# # print('Job is still running\n')
# # print('To reconnect to the job:\n')
# # print(' catalearn.reconnect()\n')
# # print('To stop the job:\n')
# # print(' catalearn.stop()\n')
# print('Job aborted')
# abort_and_print_credit()
return wrap
评论列表
文章目录