diff --git a/choreographer/browser_async.py b/choreographer/browser_async.py index fa4bcc5b..6f08e6cc 100644 --- a/choreographer/browser_async.py +++ b/choreographer/browser_async.py @@ -110,6 +110,10 @@ def __init__( parser=parser, ) + def is_isolated(self) -> bool: + """Return if process is isolated.""" + return self._browser_impl.is_isolated() + async def open(self) -> None: """Open the browser.""" _logger.info("Opening browser.") @@ -240,10 +244,11 @@ async def __aexit__( async def _watchdog(self) -> None: with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=TmpDirWarning) - _logger.debug("Starting watchdog") + _logger.debug("In watchdog") loop = asyncio.get_running_loop() + _logger.debug2("Running wait.") await loop.run_in_executor(None, self.subprocess.wait) - _logger.warning("Browser is being closed by watchdog.") + _logger.warning("Wait expired, Browser is being closed by watchdog.") self._watch_dog_task = None await self.close() await asyncio.sleep(1) diff --git a/choreographer/browsers/_interface_type.py b/choreographer/browsers/_interface_type.py index 6e3f12de..a25c6e70 100644 --- a/choreographer/browsers/_interface_type.py +++ b/choreographer/browsers/_interface_type.py @@ -25,3 +25,4 @@ def get_popen_args(self) -> Mapping[str, Any]: ... def get_cli(self) -> Sequence[str]: ... def get_env(self) -> MutableMapping[str, str]: ... def clean(self) -> None: ... + def is_isolated(self) -> bool: ... diff --git a/choreographer/browsers/chromium.py b/choreographer/browsers/chromium.py index f2f978e4..6541bd3a 100644 --- a/choreographer/browsers/chromium.py +++ b/choreographer/browsers/chromium.py @@ -148,12 +148,24 @@ def __init__( if not isinstance(channel, Pipe): raise NotImplementedError("Websocket style channels not implemented yet.") + self._is_isolated = "snap" in str(self.path) + self.tmp_dir = TmpDirectory( path=self._tmp_dir_path, - sneak="snap" in str(self.path), + sneak=self._is_isolated, ) _logger.info(f"Temporary directory at: {self.tmp_dir.path}") + def is_isolated(self) -> bool: + """ + Return if /tmp directory is isolated by OS. + + Returns: + bool indicating if /tmp is isolated. + + """ + return self._is_isolated + def get_popen_args(self) -> Mapping[str, Any]: """Return the args needed to runc chromium with `subprocess.Popen()`.""" args = {}