mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-03 06:14:32 +01:00
Kill all subprocesses (#265)
Co-authored-by: merwanehamadi <merwanehamadi@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import sys
|
||||
import time
|
||||
from typing import Any, Dict
|
||||
|
||||
import psutil
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from agbenchmark.start_benchmark import CURRENT_DIRECTORY, HOME_DIRECTORY
|
||||
@@ -67,7 +68,11 @@ def run_agent(
|
||||
|
||||
if time.time() - start_time > timeout:
|
||||
print("The Python function has exceeded the time limit and was terminated.")
|
||||
process.kill()
|
||||
parent = psutil.Process(process.pid)
|
||||
for child in parent.children(recursive=True):
|
||||
child.kill()
|
||||
parent.kill()
|
||||
|
||||
else:
|
||||
print("The Python function has finished running.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user