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

Include the process PID in the log lines

This will help debugging the crazy double-Blender-running we're seeing
in the studio.
parent c1bc3fc1
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ changed functionality, fixed bugs). ...@@ -24,6 +24,7 @@ changed functionality, fixed bugs).
status `error` and sleep for 10 minutes before trying again. status `error` and sleep for 10 minutes before trying again.
- Subprocess commands now write the spawned process PID in a text file, and refuse to run if there - Subprocess commands now write the spawned process PID in a text file, and refuse to run if there
already is such a file with an alive PID. already is such a file with an alive PID.
- Log lines produced by subprocesses are now prefixed with 'PID=nnn'.
## Version 2.1.0 (2018-01-04) ## Version 2.1.0 (2018-01-04)
......
...@@ -517,7 +517,7 @@ class AbstractSubprocessCommand(AbstractCommand): ...@@ -517,7 +517,7 @@ class AbstractSubprocessCommand(AbstractCommand):
async def process_line(self, line: str) -> typing.Optional[str]: async def process_line(self, line: str) -> typing.Optional[str]:
"""Processes the line, returning None to ignore it.""" """Processes the line, returning None to ignore it."""
return '> %s' % line return 'PID=%d > %s' % (self.proc.pid, line)
async def abort(self): async def abort(self):
"""Aborts the command by killing the subprocess.""" """Aborts the command by killing the subprocess."""
......
...@@ -86,14 +86,15 @@ class ExecCommandTest(AbstractCommandTest): ...@@ -86,14 +86,15 @@ class ExecCommandTest(AbstractCommandTest):
0.6 0.6
)) ))
self.assertTrue(ok) self.assertTrue(ok)
pid = cmd.proc.pid
# Check that both lines have been reported. # Check that both lines have been reported.
self.fworker.register_log.assert_has_calls([ self.fworker.register_log.assert_has_calls([
call('exec: Starting'), call('exec: Starting'),
call('Executing %s', call('Executing %s',
'%s -c \'print("hello, this is two lines\\nYes, really.")\'' % sys.executable), '%s -c \'print("hello, this is two lines\\nYes, really.")\'' % sys.executable),
call('> hello, this is two lines'), # note the logged line doesn't end in a newline call('PID=%d > hello, this is two lines' % pid),
call('> Yes, really.'), # note the logged line doesn't end in a newline call('PID=%d > Yes, really.' % pid), # note the logged line doesn't end in a newline
call('exec: Finished'), call('exec: Finished'),
]) ])
...@@ -151,13 +152,14 @@ class ExecCommandTest(AbstractCommandTest): ...@@ -151,13 +152,14 @@ class ExecCommandTest(AbstractCommandTest):
0.6 0.6
)) ))
self.assertFalse(ok) self.assertFalse(ok)
pid = cmd.proc.pid
# Check that the execution error has been reported. # Check that the execution error has been reported.
self.fworker.register_log.assert_has_calls([ self.fworker.register_log.assert_has_calls([
call('exec: Starting'), call('exec: Starting'),
call('Executing %s', call('Executing %s',
'%s -c \'raise SystemExit("¡FAIL!")\'' % sys.executable), '%s -c \'raise SystemExit("¡FAIL!")\'' % sys.executable),
call('> ¡FAIL!'), # 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 failed with status 1') 'Command failed with status 1')
]) ])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment