Skip to content
Snippets Groups Projects
Commit 6acbc2cc authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Fix logging failed command

parent 49b53b71
Branches
Tags
No related merge requests found
...@@ -508,12 +508,12 @@ class AbstractSubprocessCommand(AbstractCommand): ...@@ -508,12 +508,12 @@ class AbstractSubprocessCommand(AbstractCommand):
await self.worker.register_log(processed_line) await self.worker.register_log(processed_line)
retcode = await self.proc.wait() retcode = await self.proc.wait()
cmdline = ' '.join(shlex.quote(arg) for arg in args) self._log.info('Command %s (pid=%d) stopped with status code %s',
self._log.info('Command %r (pid=%d) stopped with status code %s', cmdline, pid, retcode) cmd_to_log, pid, retcode)
if retcode: if retcode:
raise CommandExecutionError('Command %r (pid=%d) failed with status %s' % raise CommandExecutionError('Command %s (pid=%d) failed with status %s' %
(cmdline, pid, retcode)) (cmd_to_log, pid, retcode))
except asyncio.CancelledError: except asyncio.CancelledError:
self._log.info('asyncio task got canceled, killing subprocess pid=%d', pid) self._log.info('asyncio task got canceled, killing subprocess pid=%d', pid)
await self.abort() await self.abort()
......
...@@ -162,11 +162,11 @@ class ExecCommandTest(AbstractCommandTest): ...@@ -162,11 +162,11 @@ class ExecCommandTest(AbstractCommandTest):
'%s -c \'raise SystemExit("¡FAIL!")\'' % sys.executable), '%s -c \'raise SystemExit("¡FAIL!")\'' % sys.executable),
call('pid=%d > ¡FAIL!' % pid), # note the logged line doesn't end in a newline call('pid=%d > ¡FAIL!' % pid), # note the logged line doesn't end in a newline
call('exec.(task_id=12345, command_idx=0): Error executing: ' call('exec.(task_id=12345, command_idx=0): Error executing: '
'Command pid=%d failed with status 1' % pid) 'Command %s (pid=%d) failed with status 1' % (settings['cmd'], pid))
]) ])
# The update should NOT contain a new task status -- that is left to the Worker. # The update should NOT contain a new task status -- that is left to the Worker.
self.fworker.register_task_update.assert_called_with( self.fworker.register_task_update.assert_called_with(
activity='exec.(task_id=12345, command_idx=0): Error executing: ' activity='exec.(task_id=12345, command_idx=0): Error executing: '
'Command pid=%d failed with status 1' % pid, 'Command %s (pid=%d) failed with status 1' % (settings['cmd'], pid),
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment