try
This commit is contained in:
+4
-18
@@ -1693,29 +1693,15 @@ def is_any_script_running():
|
|||||||
if entry.get("status") == "running" and entry.get("pid"):
|
if entry.get("status") == "running" and entry.get("pid"):
|
||||||
try:
|
try:
|
||||||
# Verify the process is still running
|
# Verify the process is still running
|
||||||
|
import psutil
|
||||||
process = psutil.Process(entry["pid"])
|
process = psutil.Process(entry["pid"])
|
||||||
if process.is_running():
|
if process.is_running():
|
||||||
logger.debug(f"Active script detected: {entry['script_name']} (PID: {entry['pid']})")
|
|
||||||
return True
|
return True
|
||||||
else:
|
except Exception:
|
||||||
# Process is dead, mark as stopped
|
continue
|
||||||
entry["status"] = "stopped"
|
|
||||||
entry["stop_time"] = datetime.now(timezone.utc).isoformat()
|
|
||||||
entry["pid"] = None
|
|
||||||
logger.debug(f"Marked stale script as stopped: {entry['script_name']}")
|
|
||||||
except psutil.NoSuchProcess:
|
|
||||||
# Process doesn't exist, mark as stopped
|
|
||||||
entry["status"] = "stopped"
|
|
||||||
entry["stop_time"] = datetime.now(timezone.utc).isoformat()
|
|
||||||
entry["pid"] = None
|
|
||||||
logger.debug(f"Marked stale script as stopped: {entry['script_name']}")
|
|
||||||
|
|
||||||
# Save updated activities if any were marked as stopped
|
|
||||||
save_json_file(activity_file, activities)
|
|
||||||
logger.debug("No active scripts detected")
|
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to check system_activity.json: {e}")
|
logging.error(f"Failed to check system_activity.json: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def initialize_rate_limit_info():
|
def initialize_rate_limit_info():
|
||||||
|
|||||||
Reference in New Issue
Block a user