Launch a new browser instance using the specified plugin.
(self, page_id: str, plugin: BrowserPlugin)
| 360 | self._inactive_browsers.append(browser) |
| 361 | |
| 362 | async def _launch_new_browser(self, page_id: str, plugin: BrowserPlugin) -> BrowserController: |
| 363 | """Launch a new browser instance using the specified plugin.""" |
| 364 | await self._execute_hooks(self._pre_launch_hooks, page_id, plugin) |
| 365 | browser = await plugin.new_browser() |
| 366 | |
| 367 | try: |
| 368 | await self._execute_hooks(self._post_launch_hooks, page_id, browser) |
| 369 | except BaseException: |
| 370 | # Catch BaseException to also clean up on CancelledError raised by the outer |
| 371 | # asyncio.wait_for(operation_timeout) wrapping this call. |
| 372 | try: |
| 373 | await browser.close(force=True) |
| 374 | except Exception: |
| 375 | logger.exception('Failed to close browser after post_launch_hook error.') |
| 376 | raise |
| 377 | |
| 378 | self._active_browsers.append(browser) |
| 379 | return browser |
| 380 | |
| 381 | def _identify_inactive_browsers(self) -> None: |
| 382 | """Identify inactive browsers and move them to the inactive list if their idle time exceeds the threshold.""" |
no test coverage detected