Skip to content

Commit da164d2

Browse files
authored
Merge pull request #34 from ClericPy/dev
2.3.5
2 parents abc172a + 0277d20 commit da164d2

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

ichrome/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .logs import logger
77
from .sync_utils import Chrome, Tab
88

9-
__version__ = "2.3.4"
9+
__version__ = "2.3.5"
1010
__tips__ = "[github]: https://github.com/ClericPy/ichrome\n[cdp]: https://chromedevtools.github.io/devtools-protocol/\n[cmd args]: https://peter.sh/experiments/chromium-command-line-switches/"
1111
__all__ = [
1212
'Chrome', 'ChromeDaemon', 'Tab', 'Tag', 'AsyncChrome', 'AsyncTab', 'logger',

ichrome/daemon.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,14 @@ def _start_chrome_process(self):
317317

318318
def launch_chrome(self):
319319
self._start_chrome_process()
320-
return self.check_chrome_ready()
320+
error = None
321+
if not self.proc_ok:
322+
error = f'launch_chrome failed for proc not ok'
323+
elif not self.connection_ok:
324+
error = f'launch_chrome failed for connection not ok'
325+
if error:
326+
logger.error(error)
327+
raise RuntimeError(error)
321328

322329
def check_chrome_ready(self):
323330
if self.ok:
@@ -603,7 +610,14 @@ async def restart(self):
603610

604611
async def launch_chrome(self):
605612
await self.loop.run_in_executor(None, self._start_chrome_process)
606-
return await self.ok
613+
error = None
614+
if not self.proc_ok:
615+
error = f'launch_chrome failed for proc not ok'
616+
elif not await self.connection_ok:
617+
error = f'launch_chrome failed for connection not ok'
618+
if error:
619+
logger.error(error)
620+
raise RuntimeError(error)
607621

608622
async def check_connection(self):
609623
url = self.server + "/json"

ichrome/debugger.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ def new_tab(self, url: str = ""):
178178
return None
179179

180180
def __del__(self):
181-
self.run_sync(self._self.__aexit__(None, None, None))
181+
try:
182+
self.run_sync(self._self.__aexit__(None, None, None))
183+
except RuntimeError:
184+
# for running loop error
185+
pass
182186

183187
def __str__(self):
184188
return f"{self.__class__.__name__}({self._self.host}:{self._self.port})"

0 commit comments

Comments
 (0)