Addressing sys.excepthook error in bash script

前端 未结 3 1355
暗喜
暗喜 2021-01-12 06:46

I\'ve written a bash script that is doing exactly what I want it to do, but kicking out the following error:

close failed in file object destructor: sys.except

3条回答
  •  死守一世寂寞
    2021-01-12 07:26

    I was seeing this error when piping output from a Python 2.6.2 script into the head command in bash on Ubuntu 9.04. I added try blocks to close stdout and stderr before exiting the script:

    try:
        sys.stdout.close()
    except:
        pass
    try:
        sys.stderr.close()
    except:
        pass
    

    I am no longer seeing the error.

提交回复
热议问题