Skip to content

[BUG] sys.stderr.fileno() throws an NotImplementedError exception #2034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
saurav-orca opened this issue Aug 6, 2023 · 0 comments · Fixed by #2040
Closed

[BUG] sys.stderr.fileno() throws an NotImplementedError exception #2034

saurav-orca opened this issue Aug 6, 2023 · 0 comments · Fixed by #2040
Labels

Comments

@saurav-orca
Copy link

saurav-orca commented Aug 6, 2023

System info

  • Playwright Version: [v1.36.0]
  • Operating System: [Linux and macOS]
  • Browser: [Chromium - but maybe all]
  • Other info:

Actual

Related to #246

Running playwright tasks inside faust stream process (faust-streaming = "^0.10.11"), I got an exception. It errors out on sys.stderr.fileno() line with raise NotImplementedError() error.

    try:
        # when using pythonw, sys.stderr is None.
        # when Pyinstaller is used, there is no closed attribute because Pyinstaller monkey-patches it with a NullWriter class
        if sys.stderr is None or not hasattr(sys.stderr, "closed"):
            return None
        if sys.stderr.closed:
            return None

----->  return sys.stderr.fileno()
    except (AttributeError, io.UnsupportedOperation):
        # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.
        # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors
        # This is potentially dangerous, but the best we can do.
        if not hasattr(sys, "__stderr__") or not sys.__stderr__:
            return None

        return sys.__stderr__.fileno()

Expected

Adding NotImplementedError also to the exception block resolves this issue. And handles case where fileno() is not implemented. I'm not sure why it's the case when using faust though. But covering this exception, runs playwright service just fine and good

except (NotImplementedError, AttributeError, io.UnsupportedOperation):
        ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants