Skip to content

Commit

Permalink
Close page later, unpin playwright version in tests (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
elacuesta authored Aug 17, 2023
1 parent 63c1fe9 commit c0cf659
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 4 additions & 4 deletions scrapy_playwright/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,6 @@ async def _download_request_with_page(
)
request.meta["download_latency"] = time() - start_time

if not request.meta.get("playwright_include_page"):
await page.close()
self.stats.inc_value("playwright/page_count/closed")

server_ip_address = None
with suppress(AttributeError, KeyError, TypeError, ValueError):
server_addr = await response.server_addr()
Expand All @@ -362,6 +358,10 @@ async def _download_request_with_page(
with suppress(AttributeError):
request.meta["playwright_security_details"] = await response.security_details()

if not request.meta.get("playwright_include_page"):
await page.close()
self.stats.inc_value("playwright/page_count/closed")

body, encoding = _encode_body(headers=headers, text=body_str)
respcls = responsetypes.from_args(headers=headers, url=page.url, body=body)
return respcls(
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ deps =
pytest_asyncio==0.21.1
pytest_cov==4.1.0
pytest_twisted==1.14
playwright==1.36.0
commands =
playwright install
py.test -vv --reactor=asyncio \
Expand Down

0 comments on commit c0cf659

Please sign in to comment.