fix: Prevent list modification during iteration in BrowserPool by vdusek · Pull Request #1703 · apify/crawlee-python

@vdusek @claude

Both `_identify_inactive_browsers` and `_close_inactive_browsers` methods
were modifying their respective lists (`_active_browsers` and
`_inactive_browsers`) while iterating over them. This is a classic bug
that can cause items to be skipped or raise RuntimeError.

The fix iterates over a copy of the list (`list(...)`) while modifying
the original, ensuring all items are properly processed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@vdusek added t-tooling

Issues with this label are in the ownership of the tooling team.

adhoc

Ad-hoc unplanned task added during the sprint.

labels

Jan 30, 2026

Pijukatel

@Pijukatel Pijukatel deleted the fix/browser-pool-list-iteration-race branch

February 20, 2026 06:56