Skip to content

Commit c0cf659

Browse files
authored
Close page later, unpin playwright version in tests (#224)
1 parent 63c1fe9 commit c0cf659

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

scrapy_playwright/handler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,6 @@ async def _download_request_with_page(
350350
)
351351
request.meta["download_latency"] = time() - start_time
352352

353-
if not request.meta.get("playwright_include_page"):
354-
await page.close()
355-
self.stats.inc_value("playwright/page_count/closed")
356-
357353
server_ip_address = None
358354
with suppress(AttributeError, KeyError, TypeError, ValueError):
359355
server_addr = await response.server_addr()
@@ -362,6 +358,10 @@ async def _download_request_with_page(
362358
with suppress(AttributeError):
363359
request.meta["playwright_security_details"] = await response.security_details()
364360

361+
if not request.meta.get("playwright_include_page"):
362+
await page.close()
363+
self.stats.inc_value("playwright/page_count/closed")
364+
365365
body, encoding = _encode_body(headers=headers, text=body_str)
366366
respcls = responsetypes.from_args(headers=headers, url=page.url, body=body)
367367
return respcls(

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ deps =
77
pytest_asyncio==0.21.1
88
pytest_cov==4.1.0
99
pytest_twisted==1.14
10-
playwright==1.36.0
1110
commands =
1211
playwright install
1312
py.test -vv --reactor=asyncio \

0 commit comments

Comments
 (0)