Skip to content

[Question]: Task was destroyed but it is pending! in route.abort() #1402

@cyberfuhrer

Description

@cyberfuhrer

Your question

Why am I getting an error in route.abort()?
Example:

from playwright.sync_api import sync_playwright

def handle_route(route):
    if route.request.resource_type == "image":
        response = page.request.fetch(route.request)
	if int(response.headers['content-length']) > 500:
	    route.abort()
	else:
	    route.continue_()
    else:
        route.continue_()

playwright = sync_playwright().start()
browser = playwright.chromium.launch()
context = browser.new_context()
context.route('**/*', handle_route)
page = context.new_page()
page.goto(url='https://www.pinterest.com/', timeout=10000)
page.wait_for_timeout(3000)
page.close()
context.close()
browser.close()
Task was destroyed but it is pending!
task: <Task pending coro=<BrowserContext._on_route() running at /usr/local/lib/python3.7/dist-packages/playwright/_impl/_browser_context.py:187> wait_for=<_GatheringFuture pending cb=[<TaskWakeupMethWrapper object at 0x7f2c168870d8>()]>>
...

Playwright version 1.23.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions