Skip to content

Commit f95e6d1

Browse files
authored
Fix OpenAI LLM test memory exhaustion (#3291)
1 parent d103d17 commit f95e6d1

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

test/sdk/core/models/test_openai_llm.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,10 @@ def __init__(self, *a, **k):
103103
sys.modules["smolagents.models"] = sa_mod
104104

105105
_setup_stubs()
106-
# Now that stubs are in place, attempt to execute the module so imports resolve to our stubs.
107-
# If this early import fails, clean up the partial module so the later, properly-patched import can run.
108-
try:
109-
spec.loader.exec_module(openai_llm_module)
110-
OpenAIModel = getattr(openai_llm_module, "OpenAIModel", None)
111-
except Exception:
112-
# Remove any partially-imported module to avoid interfering with later imports
113-
if MODULE_NAME in sys.modules:
114-
del sys.modules[MODULE_NAME]
115-
OpenAIModel = None
106+
# Do not execute the module here. The import below runs after the full mock
107+
# graph is installed; importing it twice can initialise the real monitoring
108+
# stack during collection and exhaust local resources.
109+
OpenAIModel = None
116110

117111

118112
def make_chunk(content, reasoning=None, role=None):

0 commit comments

Comments
 (0)