From 2040014f0d3a222adedc5a6f82564b706fa06e28 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Sun, 20 Apr 2025 11:11:18 -0400 Subject: [PATCH 1/3] Fix a memory leak in CDP Mode --- seleniumbase/plugins/sb_manager.py | 6 ++++++ seleniumbase/undetected/cdp_driver/connection.py | 3 +++ 2 files changed, 9 insertions(+) diff --git a/seleniumbase/plugins/sb_manager.py b/seleniumbase/plugins/sb_manager.py index 17111ab84e0..510c3d9e03d 100644 --- a/seleniumbase/plugins/sb_manager.py +++ b/seleniumbase/plugins/sb_manager.py @@ -1367,6 +1367,12 @@ def SB( "%s%s%s%s%s" % (c1, left_space, end_text, right_space, cr) ) + if hasattr(sb_config, "_cdp_aclose"): + import asyncio + with suppress(Exception): + loop = asyncio.get_event_loop() + asyncio.set_event_loop(loop) + loop.run_until_complete(sb_config._cdp_aclose()) gc.collect() if test and test_name and not test_passed and raise_test_failure: raise exception diff --git a/seleniumbase/undetected/cdp_driver/connection.py b/seleniumbase/undetected/cdp_driver/connection.py index 83643feb9b9..634c05db4d6 100644 --- a/seleniumbase/undetected/cdp_driver/connection.py +++ b/seleniumbase/undetected/cdp_driver/connection.py @@ -19,6 +19,7 @@ ) import websockets from websockets.protocol import State +from seleniumbase import config as sb_config from . import cdp_util as util import mycdp as cdp import mycdp.network @@ -270,6 +271,7 @@ async def aopen(self, **kw): max_size=MAX_SIZE, ) self.listener = Listener(self) + sb_config._cdp_aclose = self.aclose except (Exception,) as e: logger.debug("Exception during opening of websocket: %s", e) if self.listener: @@ -415,6 +417,7 @@ async def send( if not _is_update: await self._register_handlers() await self.websocket.send(tx.message) + sb_config._cdp_aclose = self.aclose try: return await tx except ProtocolException as e: From 51cefe6e58c55e3f5cee73747ccd4162e2af861d Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Sun, 20 Apr 2025 11:11:31 -0400 Subject: [PATCH 2/3] Version 4.37.4 --- seleniumbase/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index 5dd0bd649fc..264d26169f1 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "4.37.3" +__version__ = "4.37.4" From 9cc66b9146491eeee5181b1839d9b75b960d8360 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Sun, 20 Apr 2025 11:17:57 -0400 Subject: [PATCH 3/3] Refresh Python dependencies --- mkdocs_build/requirements.txt | 2 +- requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mkdocs_build/requirements.txt b/mkdocs_build/requirements.txt index 5e643c84f3b..de38a770118 100644 --- a/mkdocs_build/requirements.txt +++ b/mkdocs_build/requirements.txt @@ -3,7 +3,7 @@ regex>=2024.11.6 pymdown-extensions>=10.14.3 -pipdeptree>=2.26.0 +pipdeptree>=2.26.1 python-dateutil>=2.8.2 Markdown==3.8 click==8.1.8 diff --git a/requirements.txt b/requirements.txt index c54a1a4b879..9edf40c717e 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ pip>=25.0.1 packaging>=25.0 setuptools~=70.2;python_version<"3.10" -setuptools>=78.1.0;python_version>="3.10" +setuptools>=78.1.1;python_version>="3.10" wheel>=0.45.1 attrs>=25.3.0 certifi>=2025.1.31 diff --git a/setup.py b/setup.py index 5a8ddedfe19..f7b74a2ecf9 100755 --- a/setup.py +++ b/setup.py @@ -150,7 +150,7 @@ 'pip>=25.0.1', 'packaging>=25.0', 'setuptools~=70.2;python_version<"3.10"', # Newer ones had issues - 'setuptools>=78.1.0;python_version>="3.10"', + 'setuptools>=78.1.1;python_version>="3.10"', 'wheel>=0.45.1', 'attrs>=25.3.0', "certifi>=2025.1.31",