AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Kill all subprocesses (#265)
Erik Petersonfa8f010e800a
diff --git a/agbenchmark/agent_interface.py b/agbenchmark/agent_interface.pyindex 6b2d5bbe74..d93fe12e12 100644--- a/agbenchmark/agent_interface.py+++ b/agbenchmark/agent_interface.py@@ -6,6 +6,7 @@ import sysimport timefrom typing import Any, Dict+import psutilfrom dotenv import load_dotenvfrom 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.")