<tfoot id='MIBI9'></tfoot>

  • <legend id='MIBI9'><style id='MIBI9'><dir id='MIBI9'><q id='MIBI9'></q></dir></style></legend>

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

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

        • <bdo id='MIBI9'></bdo><ul id='MIBI9'></ul>

        将超时参数添加到 python 的 Queue.join()

        Add timeout argument to python#39;s Queue.join()(将超时参数添加到 python 的 Queue.join())
        <tfoot id='NLDkH'></tfoot>
          • <legend id='NLDkH'><style id='NLDkH'><dir id='NLDkH'><q id='NLDkH'></q></dir></style></legend>
              • <bdo id='NLDkH'></bdo><ul id='NLDkH'></ul>
                1. <small id='NLDkH'></small><noframes id='NLDkH'>

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

                  本文介绍了将超时参数添加到 python 的 Queue.join()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我希望能够加入()队列类,但如果调用尚未返回,则在一段时间后超时.最好的方法是什么?是否可以通过子类化队列使用元类来做到这一点?

                  I want to be able to join() the Queue class but timeouting after some time if the call hasn't returned yet. What is the best way to do it? Is it possible to do it by subclassing queueusing metaclass?

                  推荐答案

                  子类化 Queue 可能是最好的方法.像这样的东西应该可以工作(未经测试):

                  Subclassing Queue is probably the best way. Something like this should work (untested):

                  def join_with_timeout(self, timeout):
                      self.all_tasks_done.acquire()
                      try:
                          endtime = time() + timeout
                          while self.unfinished_tasks:
                              remaining = endtime - time()
                              if remaining <= 0.0:
                                  raise NotFinished
                              self.all_tasks_done.wait(remaining)
                      finally:
                          self.all_tasks_done.release()
                  

                  这篇关于将超时参数添加到 python 的 Queue.join()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 数据框制作线图?)

                          <tbody id='mZlaI'></tbody>

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

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