Add debug output to kill_job to diagnose kill failure
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
22
tui/jobs.py
22
tui/jobs.py
@@ -93,12 +93,24 @@ class JobManager:
|
|||||||
except (ProcessLookupError, OSError):
|
except (ProcessLookupError, OSError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def kill_job(self, job_id: str) -> bool:
|
def kill_job(self, job_id: str) -> str:
|
||||||
|
"""Kill a job. Returns a status message for debugging."""
|
||||||
job = self._jobs.get(job_id)
|
job = self._jobs.get(job_id)
|
||||||
if not job or job._proc is None:
|
if not job:
|
||||||
return False
|
return "job not found"
|
||||||
self._kill_process_group(job._proc)
|
if job._proc is None:
|
||||||
return True
|
return f"proc is None (status={job.status})"
|
||||||
|
pid = job._proc.pid
|
||||||
|
try:
|
||||||
|
pgid = os.getpgid(pid)
|
||||||
|
os.killpg(pgid, signal.SIGKILL)
|
||||||
|
return f"killed pgid={pgid} (pid={pid})"
|
||||||
|
except (ProcessLookupError, PermissionError, OSError) as e:
|
||||||
|
try:
|
||||||
|
job._proc.kill()
|
||||||
|
return f"fallback kill pid={pid} ({e})"
|
||||||
|
except (ProcessLookupError, OSError) as e2:
|
||||||
|
return f"failed: {e}, {e2}"
|
||||||
|
|
||||||
def kill_running(self) -> None:
|
def kill_running(self) -> None:
|
||||||
for job in self._jobs.values():
|
for job in self._jobs.values():
|
||||||
|
|||||||
@@ -104,10 +104,8 @@ class RunningTasksScreen(Screen):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _do_kill(self, job_id: str) -> None:
|
def _do_kill(self, job_id: str) -> None:
|
||||||
if job_manager.kill_job(job_id):
|
result = job_manager.kill_job(job_id)
|
||||||
self.notify("Job killed")
|
self.notify(f"Kill: {result}")
|
||||||
else:
|
|
||||||
self.notify("Could not kill job", severity="error")
|
|
||||||
|
|
||||||
def action_go_back(self) -> None:
|
def action_go_back(self) -> None:
|
||||||
self.app.pop_screen()
|
self.app.pop_screen()
|
||||||
|
|||||||
Reference in New Issue
Block a user