Skip to content
Snippets Groups Projects
Commit 46526163 authored by Anael Beutot's avatar Anael Beutot
Browse files

Improved logging for ForkedJob

parent 932fa56f
No related branches found
No related tags found
No related merge requests found
......@@ -262,7 +262,7 @@ class ForkedJob(object):
try:
self.fork_pid = os.fork()
except OSError as exc:
logger.error('Cannot fork: %s', os.strerror(exc.errno))
logger.error('Cannot fork (job %s): %s', self.id, os.strerror(exc.errno))
raise
self.running = True
......@@ -274,10 +274,10 @@ class ForkedJob(object):
try:
self.run_job()
except:
sys.stderr.write('Error during job\n')
sys.stderr.write('Error during job %s\n' % self.id)
os._exit(1)
else:
sys.stderr.write('Job execution went well\n')
sys.stderr.write('Job execution went well %s\n' % self.id)
os._exit(0)
else:
# close child fds
......@@ -287,7 +287,8 @@ class ForkedJob(object):
except OSError as exc:
if exc.errno == errno.EBADF:
# FIXME this is weird but it seems to happen sometimes
logger.debug('Error while closing fd in parent, EBADF')
logger.debug('Error while closing fd %s in parent,'
' EBADF (job %s', fd, self.id)
continue
logger.error('Error while closing fds in parent: %s',
os.strerror(exc.errno))
......@@ -323,8 +324,9 @@ class ForkedJob(object):
if exc.errno == errno.EINTR:
continue
logger.error('Error while waiting for child to terminate: %s',
os.strerror(exc.errno))
logger.error('Error while waiting for child to terminate:'
' %s (job %s)',
os.strerror(exc.errno), self.id)
raise
else:
break
......@@ -335,7 +337,7 @@ class ForkedJob(object):
else:
raise JobError('Exception during job, returned %s, signal'
' %s' % (
return_status,
return_status >> 8,
num_to_sig(return_status & 0xff)))
finally:
self.fork_pid = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment