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

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

      <legend id='VSjy6'><style id='VSjy6'><dir id='VSjy6'><q id='VSjy6'></q></dir></style></legend>
        <tfoot id='VSjy6'></tfoot>
        • <bdo id='VSjy6'></bdo><ul id='VSjy6'></ul>
      1. 处理(在 python 中)IOError 的正确方法是什么:[Errno 4] Interrupted system

        What is the proper way to handle (in python) IOError: [Errno 4] Interrupted system call, raised by multiprocessing.Queue.get(处理(在 python 中)IOError 的正确方法是什么:[Errno 4] Interrupted system call,由 multiprocessing.Queue.get 引发) -

            <tbody id='gV3C1'></tbody>

          <tfoot id='gV3C1'></tfoot>
        1. <legend id='gV3C1'><style id='gV3C1'><dir id='gV3C1'><q id='gV3C1'></q></dir></style></legend>

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

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

                  本文介绍了处理(在 python 中)IOError 的正确方法是什么:[Errno 4] Interrupted system call,由 multiprocessing.Queue.get 引发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我使用 multiprocessing.Queue.get 时,有时由于 EINTR 会出现异常.

                  When I use multiprocessing.Queue.get I sometimes get an exception due to EINTR.

                  我清楚地知道,有时这种情况会无缘无故地发生(我在 tmux 缓冲区中打开另一个窗格),在这种情况下,我想继续工作并重试该操作.

                  I know definitely that sometimes this happens for no good reason (I open another pane in a tmux buffr), and in such a case I would want to continue working and retry the operation.

                  我可以想象,在某些其他情况下,错误是有充分理由的,我应该停止运行或修复一些错误.

                  I can imagine that in some other cases The error would be due to a good reason and I should stop running or fix some error.

                  如何区分两者?

                  提前致谢

                  推荐答案

                  当应用程序在等待其他输入时收到信号时,许多系统调用可能会返回 EINTR 错误.通常,这些信号可能是非常良性的,并且已经由 Python 处理,但底层系统调用最终仍会被中断.在进行 C/C++ 编码时,这是您不能完全依赖像 sleep() 这样的函数的原因之一.Python 库有时会在内部处理此错误代码,但显然在这种情况下它们不是.

                  The EINTR error can be returned from many system calls when the application receives a signal while waiting for other input. Typically these signals can be quite benign and already handled by Python, but the underlying system call still ends up being interrupted. When doing C/C++ coding this is one reason why you can't entirely rely on functions like sleep(). The Python libraries sometimes handle this error code internally, but obviously in this case they're not.

                  您可能有兴趣阅读 此线程 讨论了这个问题.

                  You might be interested to read this thread which discusses this problem.

                  EINTR 的一般方法是简单地处理错误并再次重试操作 - 这应该是使用队列.可以使用类似的东西,将队列作为参数传递并替换队列上 get() 方法的使用:

                  The general approach to EINTR is to simply handle the error and retry the operation again - this should be a safe thing to do with the get() method on the queue. Something like this could be used, passing the queue as a parameter and replacing the use of the get() method on the queue:

                  import errno
                  
                  def my_queue_get(queue, block=True, timeout=None):
                      while True:
                          try:
                              return queue.get(block, timeout)
                          except IOError, e:
                              if e.errno != errno.EINTR:
                                  raise
                  
                  # Now replace instances of queue.get() with my_queue_get(queue), with other
                  # parameters passed as usual.
                  

                  通常你不需要担心 Python 程序中的 EINTR,除非你知道你正在等待一个特定的信号(例如 SIGHUP)并且你'已经安装了一个信号处理程序,它设置一个标志并依靠代码的主体来获取标志.在这种情况下,如果收到 EINTR,您可能需要跳出循环并检查信号标志.

                  Typically you shouldn't need to worry about EINTR in a Python program unless you know you're waiting for a particular signal (for example SIGHUP) and you've installed a signal handler which sets a flag and relies on the main body of the code to pick up the flag. In this case, you might need to break out of your loop and check the signal flag if you receive EINTR.

                  但是,如果您没有使用任何信号处理,那么您应该能够忽略 EINTR 并重复您的操作 - 如果 Python 本身需要对它应该已经处理的信号做一些事情在信号处理程序中使用它.

                  However, if you're not using any signal handling then you should be able to just ignore EINTR and repeat your operation - if Python itself needs to do something with the signal it should have already dealt with it in the signal handler.

                  这篇关于处理(在 python 中)IOError 的正确方法是什么:[Errno 4] Interrupted system call,由 multiprocessing.Queue.get 引发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                    <tfoot id='rmm0f'></tfoot>

                      <bdo id='rmm0f'></bdo><ul id='rmm0f'></ul>
                          <tbody id='rmm0f'></tbody>
                      • <legend id='rmm0f'><style id='rmm0f'><dir id='rmm0f'><q id='rmm0f'></q></dir></style></legend>

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

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