Skip to content

[BUG] Fail to close context when running inside a larger loop #1886

Closed
@AlmogBaku

Description

@AlmogBaku

Context:

  • Playwright Version: 1.32.1
  • Operating System: macos
  • Python version: [e.g. 3.7, 3.9]
  • Browser: all

Describe the bug

I'm running a gRPC server using a loop, and then using playwright to fetch some URL: https://github.com/hwchase17/langchain/blob/e3b7a20454cea592fc6d0a0d91c36206e8ad6790/langchain/document_loaders/url_playwright.py#L62

when the context is exiting, this error is thrown
RuntimeError: Set changed size during iteration

this is happening due to an old upstream bug in cpython python/cpython#80788

we need to refactor the context manager to close itself differently

for t in [t for t in tasks if not (t.done() or t.cancelled())]:

TBH, I don't know why we even do that :O

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions