Skip to content

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.

fix(backend/copilot): keep garbage collection out of the dream tests' timed runs (#15979)

Reinier van der Leerd355bd1b0583
diff --git a/autogpt_platform/backend/backend/copilot/dream/conftest.py b/autogpt_platform/backend/backend/copilot/dream/conftest.py
index bd4601c976..12ebe69aba 100644
--- a/autogpt_platform/backend/backend/copilot/dream/conftest.py
+++ b/autogpt_platform/backend/backend/copilot/dream/conftest.py
@@ -22,6 +22,8 @@ with, and a batch's status reads ended, unless a test sets its own.
from __future__ import annotations
import asyncio
+import gc
+from collections.abc import Iterator
from datetime import datetime, timezone
from enum import Enum
from typing import Any
@@ -59,6 +61,17 @@ async def graph_cleanup():
yield
[email protected](autouse=True)
+def no_gc_during_test() -> Iterator[None]:
+ """These tests time the loop against budgets of tenths of a second, and a
+ full collection over the suite's heap stalls it for over a second on CI."""
+ enabled = gc.isenabled()
+ gc.disable()
+ yield
+ if enabled:
+ gc.enable()
+
+
class FakeAsyncRedis:
"""In-memory stand-in for the ``decode_responses=True`` async client.