<i id='wH1e0'><tr id='wH1e0'><dt id='wH1e0'><q id='wH1e0'><span id='wH1e0'><b id='wH1e0'><form id='wH1e0'><ins id='wH1e0'></ins><ul id='wH1e0'></ul><sub id='wH1e0'></sub></form><legend id='wH1e0'></legend><bdo id='wH1e0'><pre id='wH1e0'><center id='wH1e0'></center></pre></bdo></b><th id='wH1e0'></th></span></q></dt></tr></i><div id='wH1e0'><tfoot id='wH1e0'></tfoot><dl id='wH1e0'><fieldset id='wH1e0'></fieldset></dl></div>
    • <bdo id='wH1e0'></bdo><ul id='wH1e0'></ul>

        <legend id='wH1e0'><style id='wH1e0'><dir id='wH1e0'><q id='wH1e0'></q></dir></style></legend>

        <small id='wH1e0'></small><noframes id='wH1e0'>

        <tfoot id='wH1e0'></tfoot>

        什么会导致“IOError: [Errno 9] Bad file descriptor"?在 os.syst

        What can lead to quot;IOError: [Errno 9] Bad file descriptorquot; during os.system()?(什么会导致“IOError: [Errno 9] Bad file descriptor?在 os.system() 期间?)
      1. <legend id='gGlO1'><style id='gGlO1'><dir id='gGlO1'><q id='gGlO1'></q></dir></style></legend>
          <bdo id='gGlO1'></bdo><ul id='gGlO1'></ul>

              • <tfoot id='gGlO1'></tfoot>
              • <small id='gGlO1'></small><noframes id='gGlO1'>

                    <tbody id='gGlO1'></tbody>
                • <i id='gGlO1'><tr id='gGlO1'><dt id='gGlO1'><q id='gGlO1'><span id='gGlO1'><b id='gGlO1'><form id='gGlO1'><ins id='gGlO1'></ins><ul id='gGlO1'></ul><sub id='gGlO1'></sub></form><legend id='gGlO1'></legend><bdo id='gGlO1'><pre id='gGlO1'><center id='gGlO1'></center></pre></bdo></b><th id='gGlO1'></th></span></q></dt></tr></i><div id='gGlO1'><tfoot id='gGlO1'></tfoot><dl id='gGlO1'><fieldset id='gGlO1'></fieldset></dl></div>
                  本文介绍了什么会导致“IOError: [Errno 9] Bad file descriptor"?在 os.system() 期间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用一个科学软件,其中包括一个调用 os.system() 的 Python 脚本,该脚本用于运行另一个科学程序.当子进程运行时,Python 有时会打印以下内容:

                  I am using a scientific software including a Python script that is calling os.system() which is used to run another scientific program. While the subprocess is running, Python at some point prints the following:

                  close failed in file object destructor:
                  IOError: [Errno 9] Bad file descriptor
                  

                  我相信这条消息是在 os.system() 返回的同时打印出来的.

                  I believe that this message is printed at the same time as os.system() returns.

                  我现在的问题是:

                  哪些情况会导致这种类型的 IOError?它到底是什么意思?os.system()调用的子进程是什么意思?

                  Which conditions can lead to this type of IOError? What does it exactly mean? What does it mean for the subprocess that has been invoked by os.system()?

                  推荐答案

                  如果 Python 文件从外部"关闭,即不是从文件对象的 close() 关闭,则会收到此错误消息方法:

                  You get this error message if a Python file was closed from "the outside", i.e. not from the file object's close() method:

                  >>> f = open(".bashrc")
                  >>> os.close(f.fileno())
                  >>> del f
                  close failed in file object destructor:
                  IOError: [Errno 9] Bad file descriptor
                  

                  del f 行删除了对文件对象的最后一个引用,导致其析构函数 file.__del__ 被调用.文件对象的内部状态表明文件仍然打开,因为 f.close() 从未被调用,因此析构函数尝试关闭文件.由于试图关闭未打开的文件,操作系统随后会引发错误.

                  The line del f deletes the last reference to the file object, causing its destructor file.__del__ to be called. The internal state of the file object indicates the file is still open since f.close() was never called, so the destructor tries to close the file. The OS subsequently throws an error because of the attempt to close a file that's not open.

                  由于 os.system() 的实现不会创建任何 Python 文件对象,因此 system() 调用似乎不太可能是错误.也许您可以显示更多代码?

                  Since the implementation of os.system() does not create any Python file objects, it does not seem likely that the system() call is the origin of the error. Maybe you could show a bit more code?

                  这篇关于什么会导致“IOError: [Errno 9] Bad file descriptor"?在 os.system() 期间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pythonic and efficient way of finding adjacent cells in grid(在网格中查找相邻单元格的 Pythonic 和有效方法)
                  map a hexagonal grid in matplotlib(在 matplotlib 中映射六边形网格)
                  Execute arbitrary python code remotely - can it be done?(远程执行任意 python 代码 - 可以吗?)
                  Python - Plotting colored grid based on values(Python - 根据值绘制彩色网格)
                  Is there a GUI design app for the Tkinter / grid geometry?(是否有 Tkinter/网格几何图形的 GUI 设计应用程序?)
                  tkinter Canvas Scrollbar with Grid?(带有网格的 tkinter 画布滚动条?)
                    <tbody id='kv1fl'></tbody>
                  <legend id='kv1fl'><style id='kv1fl'><dir id='kv1fl'><q id='kv1fl'></q></dir></style></legend>
                  <i id='kv1fl'><tr id='kv1fl'><dt id='kv1fl'><q id='kv1fl'><span id='kv1fl'><b id='kv1fl'><form id='kv1fl'><ins id='kv1fl'></ins><ul id='kv1fl'></ul><sub id='kv1fl'></sub></form><legend id='kv1fl'></legend><bdo id='kv1fl'><pre id='kv1fl'><center id='kv1fl'></center></pre></bdo></b><th id='kv1fl'></th></span></q></dt></tr></i><div id='kv1fl'><tfoot id='kv1fl'></tfoot><dl id='kv1fl'><fieldset id='kv1fl'></fieldset></dl></div>
                    • <bdo id='kv1fl'></bdo><ul id='kv1fl'></ul>

                            <tfoot id='kv1fl'></tfoot>
                          • <small id='kv1fl'></small><noframes id='kv1fl'>