0

Is it possible that one could see a [Errno 9] Bad file descriptor error message caused from a print() statement?

I was facing this error at random (sometimes in a row, sometimes it did not occur at all) while running unittests. As soon as I removed the print statements that the file was complaining about things ran fine.

What would cause that error for a print message?

dataviews
  • 2,466
  • 7
  • 31
  • 64
  • Are you passing a `file=...` argument to `print()`? Or does your code muck around with `sys.stdout`? – John Gordon Aug 16 '22 at 20:18
  • @JohnGordon this file https://github.com/awslabs/python-deequ/blob/master/pydeequ/scala_utils.py is what I'm working with. Line 24 is what seems to cause issues – dataviews Aug 16 '22 at 20:54

1 Answers1

0

The error occurs when stdout is busy/locked by the system. Sounds like your program requires quite a few resources to run? In your case, I'd just wrap it in a try/except or add some delay in your code, maybe optimize the code or use another method to get reliable output.

nordmanden
  • 340
  • 1
  • 10