Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 997543d

Browse files
authoredJan 29, 2025··
fix: fix BrowserPool and PlaywrightBrowserPlugin closure (#932)
### Description - Fix the `BrowserPool` and `PlaywrightBrowserPlugin` closures. Without it, the application crashes when `PlaywrightCrawler` is run in sequence again.
1 parent 600c455 commit 997543d

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed
 

‎src/crawlee/browsers/_browser_pool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ async def __aexit__(
204204

205205
for browser in self._active_browsers + self._inactive_browsers:
206206
await browser.close(force=True)
207+
self._active_browsers.clear()
208+
self._inactive_browsers.clear()
207209

208210
for plugin in self._plugins:
209211
await plugin.__aexit__(exc_type, exc_value, exc_traceback)

‎src/crawlee/browsers/_playwright_browser_plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ async def __aexit__(
134134
raise RuntimeError(f'The {self.__class__.__name__} is not active.')
135135

136136
await self._playwright_context_manager.__aexit__(exc_type, exc_value, exc_traceback)
137+
self._playwright_context_manager = async_playwright()
137138
self._active = False
138139

139140
@override

0 commit comments

Comments
 (0)
Please sign in to comment.