From 9919a9bc284f175d7477ecc93f6d15ca8f36bc50 Mon Sep 17 00:00:00 2001 From: Emilien Devos <4016501+unixfox@users.noreply.github.com> Date: Sun, 21 Jul 2024 17:38:17 +0200 Subject: [PATCH] allow to specify more retries when connecting to the browser instance --- nodriver/core/browser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nodriver/core/browser.py b/nodriver/core/browser.py index db92988..158698c 100644 --- a/nodriver/core/browser.py +++ b/nodriver/core/browser.py @@ -263,7 +263,7 @@ async def get( await connection.sleep(0.25) return connection - async def start(self=None) -> Browser: + async def start(self, retries_connect_browser = 4) -> Browser: """launches the actual browser""" if not self: warnings.warn("use ``await Browser.create()`` to create a new instance") @@ -337,11 +337,11 @@ async def start(self=None) -> Browser: util.get_registered_instances().add(self) await asyncio.sleep(0.25) - for _ in range(5): + for _ in range(retries_connect_browser + 1): try: self.info = ContraDict(await self._http.get("version"), silent=True) except (Exception,): - if _ == 4: + if _ == retries_connect_browser: logger.debug("could not start", exc_info=True) await self.sleep(0.5) else: