Skip to content

Commit

Permalink
Merge pull request #34 from ClericPy/dev
Browse files Browse the repository at this point in the history
2.3.5
  • Loading branch information
ClericPy authored Jul 5, 2020
2 parents abc172a + 0277d20 commit da164d2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ichrome/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .logs import logger
from .sync_utils import Chrome, Tab

__version__ = "2.3.4"
__version__ = "2.3.5"
__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/"
__all__ = [
'Chrome', 'ChromeDaemon', 'Tab', 'Tag', 'AsyncChrome', 'AsyncTab', 'logger',
Expand Down
18 changes: 16 additions & 2 deletions ichrome/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,14 @@ def _start_chrome_process(self):

def launch_chrome(self):
self._start_chrome_process()
return self.check_chrome_ready()
error = None
if not self.proc_ok:
error = f'launch_chrome failed for proc not ok'
elif not self.connection_ok:
error = f'launch_chrome failed for connection not ok'
if error:
logger.error(error)
raise RuntimeError(error)

def check_chrome_ready(self):
if self.ok:
Expand Down Expand Up @@ -603,7 +610,14 @@ async def restart(self):

async def launch_chrome(self):
await self.loop.run_in_executor(None, self._start_chrome_process)
return await self.ok
error = None
if not self.proc_ok:
error = f'launch_chrome failed for proc not ok'
elif not await self.connection_ok:
error = f'launch_chrome failed for connection not ok'
if error:
logger.error(error)
raise RuntimeError(error)

async def check_connection(self):
url = self.server + "/json"
Expand Down
6 changes: 5 additions & 1 deletion ichrome/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ def new_tab(self, url: str = ""):
return None

def __del__(self):
self.run_sync(self._self.__aexit__(None, None, None))
try:
self.run_sync(self._self.__aexit__(None, None, None))
except RuntimeError:
# for running loop error
pass

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

0 comments on commit da164d2

Please sign in to comment.