Skip to content

Commit

Permalink
Bugfix/log exit code (#3362)
Browse files Browse the repository at this point in the history
* log the exit code of the spawned task

* exitcode can be negative

* mypy fixes
  • Loading branch information
rkuo-danswer authored Dec 6, 2024
1 parent 53428f6 commit 631bac4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions backend/danswer/background/celery/tasks/indexing/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,12 +640,16 @@ def connector_indexing_proxy_task(
continue

if job.status == "error":
exit_code: int | None = None
if job.process:
exit_code = job.process.exitcode
task_logger.error(
"Indexing watchdog - spawned task exceptioned: "
f"attempt={index_attempt_id} "
f"tenant={tenant_id} "
f"cc_pair={cc_pair_id} "
f"search_settings={search_settings_id} "
f"exit_code={exit_code} "
f"error={job.exception()}"
)

Expand Down
5 changes: 3 additions & 2 deletions backend/danswer/background/indexing/job_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def status(self) -> JobStatusType:
return "running"
elif self.process.exitcode is None:
return "cancelled"
elif self.process.exitcode > 0:
elif self.process.exitcode != 0:
return "error"
else:
return "finished"
Expand Down Expand Up @@ -123,7 +123,8 @@ def submit(self, func: Callable, *args: Any, pure: bool = True) -> SimpleJob | N
self._cleanup_completed_jobs()
if len(self.jobs) >= self.n_workers:
logger.debug(
f"No available workers to run job. Currently running '{len(self.jobs)}' jobs, with a limit of '{self.n_workers}'."
f"No available workers to run job. "
f"Currently running '{len(self.jobs)}' jobs, with a limit of '{self.n_workers}'."
)
return None

Expand Down

0 comments on commit 631bac4

Please sign in to comment.