Skip to content

[BUG] Playwright fails if you suppress stderr #1098

Closed
@AlberLC

Description

@AlberLC

Context:

  • Playwright Version: 1.17.2
  • Operating System: Windows 11 - 64 bits
  • Python version: 3.10
  • Browser: Chromium

npx envinfo --preset playwright --markdown:

System:

  • OS: Windows 10 10.0.22000
  • Memory: 8.05 GB / 15.92 GB

Binaries:

  • Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
  • npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD

Languages:

  • Bash: 4.4.19 - C:\Windows\system32\bash.EXE

Minimal example

import asyncio
import contextlib
import os

from playwright.async_api import async_playwright


async def a():
    with open(os.devnull, 'w') as fnull:
        with contextlib.redirect_stderr(fnull):
            await asyncio.sleep(0)


async def b():
    try:
        async with async_playwright():
            print('PLEASE WORK!')
    except ValueError as e:
        print(f':(   {e}')


async def main():
    await asyncio.gather(a(), a(), b())


if __name__ == '__main__':
    asyncio.run(main())

Expected output

PLEASE WORK!

Actual output

:( I/O operation on closed file

Description

Playwright fails if you suppress stderr.

I have detected it in a telegram bot that I have running with asyncio. If you mix tasks that affect stderr, this error occurs and playwright doesn't work or will not work until the program is completely restarted.

I am ashamed to recognize the amount of hours that I just spent to discover how to reproduce the bug in a minimal example (I have not slept today ._. ).

Metadata

Metadata

Assignees

No one assigned

    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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy