fix: add SIGKILL fallback when SIGTERM does not stop the alarm
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user