Skip to content

Commit

Permalink
Always include browser exit code in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tysmith committed Sep 15, 2023
1 parent 01cd80a commit a58b202
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/ffpuppet/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,7 @@ def close(self, force_close: bool = False) -> None:
# this can raise but shouldn't, we want to know if a timeout happens
self._proc.wait(timeout=30)

# set reason code
exit_code: Optional[int] = None
# check state of browser processes and set the close reason
if any(self._crashreports(skip_benign=True)):
r_code = Reason.ALERT
# Wait a moment for processes to exit automatically.
Expand Down Expand Up @@ -568,12 +567,11 @@ def close(self, force_close: bool = False) -> None:
# have a crash report... this should be revisited when time allows
# https://bugzil.la/1370520
# Ignore -9 to avoid false positives due to system OOM killer
exit_code = self._proc.poll()
exit_code: Optional[int] = self._proc.poll()
assert exit_code is not None
r_code = Reason.ALERT
LOG.warning(
"Browser exit code: %r (%X), no crash reports found",
exit_code,
exit_code,
"No crash reports found, exit code: %d (%X)", exit_code, exit_code
)
else:
r_code = Reason.EXITED
Expand Down Expand Up @@ -612,8 +610,7 @@ def close(self, force_close: bool = False) -> None:
)
stderr_fp = self._logs.get_fp("stderr")
if stderr_fp:
if exit_code is not None:
stderr_fp.write(f"[ffpuppet] Exit code: {exit_code}\n".encode())
stderr_fp.write(f"[ffpuppet] Exit code: {self._proc.poll()}\n".encode())
stderr_fp.write(f"[ffpuppet] Reason code: {r_code.name}\n".encode())

# reset remaining to closed state
Expand Down
2 changes: 1 addition & 1 deletion src/ffpuppet/test_ffpuppet.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ def get_processes(self):
with StubbedProc() as ffp:
ffp.launch()
proc = ffp._proc
ffp._proc.poll.side_effect = (None, 0, 0)
ffp._proc.poll.side_effect = (None, 0, 0, 0)
ffp.close()
assert ffp._proc is None
assert ffp._logs.closed
Expand Down

0 comments on commit a58b202

Please sign in to comment.