-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
ValueError: I/O operation on closed file #11439
Comments
im cuious as to why faulthandler is enabled by default i believe thats a missing case in our suite, in particualr since the ValueError comes in there |
IIRC we decided it would be more useful if it was enabled by default, given it has low impact and when crashes happen it is extremely useful. Also probably users wouldn't even know about it unless it is enabled by default. I'm curious though what caused the file handler to be closed in the first place? I suppose something in your test suite/production code doing something with that file handler? Regardless, indeed seems like the solution is just to add pytest/src/_pytest/faulthandler.py Lines 46 to 58 in 6c2feb7
|
I tried to find a call to stderr.close() in our code. It must be happening somewhere so I am curious too but I could not find anything. |
@nicoddemus no, what i meant was why the faulthandler was initially enabled, based on the error and the current code, the exception happens when trying to re-enable faulthandler in pytest shutdown based on having remembered that it was enabled |
@bnomis its thinkable that output capture was not entirely disabled yet and thus the file is currently not valid |
After all tests have finished, closing the test session, the faulthandler unconfigure function tries to get the fileno of stderr. If stderr is closed it throws a ValueError. When running in a CI it looks like tests failed since pytest exits with an error but actually all the tests have passed - just the teardown failed.
A quick fix would be to expand the scope of caught exceptions in the get_stderr_fileno() function in faulthandler.py. Currently ValueError is not caught.
Traceback
Platform
The text was updated successfully, but these errors were encountered: