Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/crawlee/browsers/_browser_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,14 @@ async def _launch_new_browser(self, plugin: BrowserPlugin) -> BrowserController:

def _identify_inactive_browsers(self) -> None:
"""Identify inactive browsers and move them to the inactive list if their idle time exceeds the threshold."""
for browser in self._active_browsers:
for browser in list(self._active_browsers):
if browser.idle_time >= self._browser_inactive_threshold:
self._active_browsers.remove(browser)
self._inactive_browsers.append(browser)

async def _close_inactive_browsers(self) -> None:
"""Close the browsers that have no active pages and have been idle for a certain period."""
for browser in self._inactive_browsers:
for browser in list(self._inactive_browsers):
if not browser.pages:
await browser.close()
self._inactive_browsers.remove(browser)
Loading