Skip to content

Commit

Permalink
Show .err when the job is killed #1323
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Dec 4, 2019
1 parent 1d01a31 commit 4289ed0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/sos/tasks.py
Expand Up @@ -977,16 +977,22 @@ def task_changed():
os.path.expanduser('~'), '.sos', 'tasks', task + '.err')

# if the system does not return any error message, write sos-specific one
if not os.path.isfile(syserr_file) or os.path.getsize(syserr_file) == 0:
if os.path.isfile(syserr_file) and os.path.getsize(syserr_file) > 0:
try:
with open(syserr_file) as syserr:
env.logger.warning(''.join(syserr.readlines()[-5:]))
except Exception as e:
env.logger.warning(f'{task} is suspected to be killed but {syserr_file} cannot be read: {e}')
else:
soserr_file = os.path.join(
os.path.expanduser('~'), '.sos', 'tasks', task + '.soserr')
with open(soserr_file, 'a') as err:
err.write(
f'Task {task} inactive for more than {int(elapsed)} seconds, might have been killed.'
)
env.logger.warning(
f'Task {task} inactive for more than {int(elapsed)} seconds, might have been killed.'
)
env.logger.warning(
f'Task {task} inactive for more than {int(elapsed)} seconds, might have been killed.'
)

tf.add_outputs()
# assume aborted
Expand Down

0 comments on commit 4289ed0

Please sign in to comment.