fix: add SIGKILL fallback when SIGTERM does not stop the alarm

This commit is contained in:
2026-06-18 17:17:56 +02:00
parent 4d9f08f21f
commit 0472de5a5d
2 changed files with 40 additions and 3 deletions
+10
View File
@@ -2,6 +2,7 @@ import strawberry
from typing import List, Optional
import os
import sys
import time
import subprocess
import signal
from pathlib import Path
@@ -138,6 +139,15 @@ class Mutation:
with open(PID_FILE) as f:
pid = int(f.read().strip())
os.kill(pid, signal.SIGTERM)
# Give the process a short grace period, then escalate to SIGKILL.
for _ in range(20):
time.sleep(0.1)
try:
os.kill(pid, 0)
except ProcessLookupError:
break
else:
os.kill(pid, signal.SIGKILL)
if os.path.exists(PID_FILE):
os.remove(PID_FILE)
return True