Skip to content
Merged
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
5 changes: 3 additions & 2 deletions scrapy_playwright/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ async def _launch(self) -> None:
"""Launch Playwright manager and configured startup context(s)."""
logger.info("Starting download handler")
self.playwright_context_manager = PlaywrightContextManager()
playwright_instance = await self.playwright_context_manager.start()
self.browser_type: BrowserType = getattr(playwright_instance, self.browser_type_name)
self.playwright = await self.playwright_context_manager.start()
self.browser_type: BrowserType = getattr(self.playwright, self.browser_type_name)
if self.startup_context_kwargs:
logger.info("Launching %i startup context(s)", len(self.startup_context_kwargs))
await asyncio.gather(
Expand Down Expand Up @@ -266,6 +266,7 @@ async def _close(self) -> None:
logger.info("Closing browser")
await self.browser.close()
await self.playwright_context_manager.__aexit__()
await self.playwright.stop()

def download_request(self, request: Request, spider: Spider) -> Deferred:
if request.meta.get("playwright"):
Expand Down