• Register
0 votes

Problem :

I have attempted to reproduce my problem described below under only Python 2.7.3.

The most reliable way that I found to elicit my problem in the question is to pipe my output of the next test script through the use of  : (under bash):

    for m in range(40):
        print m

The error message received as below :

% mypython testscript.py | :
close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr

As the test script clearly shows that the error cannot be trapped with the try-except.

My question is as below:

How can I modify my test script above to avoid facing the error message whenmy script is run as shown above (under  the Unix/bash)?

6 5 3
7,540 points

1 Answer

0 votes

Solution :

When you try to pipe the output of one program into the another, the output produced by the first  writing program gets backed up in the buffer, and it waits for your reading program to request that data from your buffer. As long as your buffer is nonempty, any attempt to made to close your writing file object is supposed to fail with the error. This is the root cause behind the messages you are expearencing.

The specific code that is triggering the error is in your C language implementation of the Python, which explains why you can not catch the error with the try/except block: as it runs after your contents of the script has finished the processing.

9 7 4
38,600 points

Related questions

0 votes
1 answer 14 views
0 votes
1 answer 89 views
Problem : I am trying to develop some selenium tests which should run with headless firefox but the following error suddenly popped up in my server.log file when I was trying to connect to the webdriver via following command: driver = webdriver.Firefox(firefox_profile = profile, log_path = ... spec as below: python 2.7.12, Firefox: Mozilla Firefox 57.0.3, geckodriver: 0.19.1, selenium: 3.8.0
asked Dec 3, 2019 alecxe 7.5k points
0 votes
1 answer 1.4K views
Problem : The import matplotlib.pyplot as plt is is giving me the error with python2.7, anaconda3. The error shown is as below: ImportError: libGL.so.1: cannot open shared object file: No such file or directory The Detailed Error report is as below : Traceback ... <module> from PyQt5 import QtCore, QtGui, QtWidgets ImportError: libGL.so.1: cannot open shared object file: No such file or directory
asked Dec 18, 2019 alecxe 7.5k points