Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
silence __del__ event loop closed errors on exit
Nick Sweetingfa6fc98783ee
diff --git a/tests/ci/test_agent_multiprocessing.py b/tests/ci/test_agent_multiprocessing.pyindex 53e901bd2..b0b7e8264 100644--- a/tests/ci/test_agent_multiprocessing.py+++ b/tests/ci/test_agent_multiprocessing.py@@ -14,6 +14,7 @@ Tests cover:import asyncioimport loggingimport multiprocessing+from asyncio import base_subprocessfrom concurrent.futures import ThreadPoolExecutorfrom unittest.mock import AsyncMock@@ -29,6 +30,29 @@ setup_logging()logger = logging.getLogger(__name__)+# Monkeypatch BaseSubprocessTransport.__del__ to handle closed event loops gracefully+original_del = base_subprocess.BaseSubprocessTransport.__del__+++def patched_del(self):+ """Patched __del__ that handles closed event loops gracefully"""+ try:+ # Check if the event loop is closed before calling the original+ if hasattr(self, '_loop') and self._loop and self._loop.is_closed():+ # Event loop is closed, skip cleanup that requires the loop+ return+ original_del(self)+ except RuntimeError as e:+ if 'Event loop is closed' in str(e):+ # Silently ignore this specific error+ pass+ else:+ raise+++base_subprocess.BaseSubprocessTransport.__del__ = patched_del++def create_mock_llm():"""Create a mock LLM that returns a done action"""mock = AsyncMock(spec=BaseChatModel)