久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <small id='aWERt'></small><noframes id='aWERt'>

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

        <tfoot id='aWERt'></tfoot>
        • <bdo id='aWERt'></bdo><ul id='aWERt'></ul>
      1. <legend id='aWERt'><style id='aWERt'><dir id='aWERt'><q id='aWERt'></q></dir></style></legend>
      2. 多處理返回“打開的文件太多";但是使用

        multiprocessing returns quot;too many open filesquot; but using `with...as` fixes it. Why?(多處理返回“打開的文件太多;但是使用 `with...as` 可以解決這個問題.為什么?)
          <tbody id='VJjk8'></tbody>

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

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

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

                  本文介紹了多處理返回“打開的文件太多";但是使用 `with...as` 可以解決這個問題.為什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我使用 this answer 以便在 Linux 機器上運行 Python 中的多處理并行命令.

                  I was using this answer in order to run parallel commands with multiprocessing in Python on a Linux box.

                  我的代碼做了類似的事情:

                  My code did something like:

                  import multiprocessing
                  import logging
                  
                  def cycle(offset):
                      # Do stuff
                  
                  def run():
                      for nprocess in process_per_cycle:
                          logger.info("Start cycle with %d processes", nprocess)
                          offsets = list(range(nprocess))
                          pool = multiprocessing.Pool(nprocess)
                          pool.map(cycle, offsets)
                  

                  但是我收到了這個錯誤:OSError: [Errno 24] Too many open files
                  因此,代碼打開了太多的文件描述符,即:它啟動了太多的進程而沒有終止它們.

                  But I was getting this error: OSError: [Errno 24] Too many open files
                  So, the code was opening too many file descriptor, i.e.: it was starting too many processes and not terminating them.

                  我修復了它,用這些行替換了最后兩行:

                  I fixed it replacing the last two lines with these lines:

                      with multiprocessing.Pool(nprocess) as pool:
                          pool.map(cycle, offsets)
                  

                  但我不知道這些行修復它的確切原因.

                  But I do not know exactly why those lines fixed it.

                  with 下面發生了什么?

                  推薦答案

                  您正在循環中創建新進程,然后在完成后忘記關閉它們.結果,您有太多打開的進程.這是個壞主意.

                  You're creating new processes inside a loop, and then forgetting to close them once you're done with them. As a result, there comes a point where you have too many open processes. This is a bad idea.

                  您可以通過使用自動調用 pool.terminate 的上下文管理器來解決此問題,或者您自己手動調用 pool.terminate.或者,你為什么不在循環外創建一個池一次,然后將任務發送到里面的進程?

                  You could fix this by using a context manager which automatically calls pool.terminate, or manually call pool.terminate yourself. Alternatively, why don't you create a pool outside the loop just once, and then send tasks to the processes inside?

                  pool = multiprocessing.Pool(nprocess) # initialise your pool
                  for nprocess in process_per_cycle:
                      ...       
                      pool.map(cycle, offsets) # delegate work inside your loop
                  
                  pool.close() # shut down the pool
                  

                  有關更多信息,您可以仔細閱讀 multiprocessing.Pool 文檔.

                  For more information, you could peruse the multiprocessing.Pool documentation.

                  這篇關于多處理返回“打開的文件太多";但是使用 `with...as` 可以解決這個問題.為什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)
                1. <small id='psXQF'></small><noframes id='psXQF'>

                  <tfoot id='psXQF'></tfoot>

                    1. <legend id='psXQF'><style id='psXQF'><dir id='psXQF'><q id='psXQF'></q></dir></style></legend>
                        <bdo id='psXQF'></bdo><ul id='psXQF'></ul>
                          <i id='psXQF'><tr id='psXQF'><dt id='psXQF'><q id='psXQF'><span id='psXQF'><b id='psXQF'><form id='psXQF'><ins id='psXQF'></ins><ul id='psXQF'></ul><sub id='psXQF'></sub></form><legend id='psXQF'></legend><bdo id='psXQF'><pre id='psXQF'><center id='psXQF'></center></pre></bdo></b><th id='psXQF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='psXQF'><tfoot id='psXQF'></tfoot><dl id='psXQF'><fieldset id='psXQF'></fieldset></dl></div>
                              <tbody id='psXQF'></tbody>
                            主站蜘蛛池模板: 国内精品久久久久久影视8 最新黄色在线观看 | 在线视频成人 | 男人的天堂久久 | 一区二区三区四区在线 | 亚洲一区二区中文字幕 | 欧美综合一区 | 超碰在线免费公开 | 日韩中文字幕在线播放 | 中文字幕免费中文 | 黄色男女网站 | 久久久国产精品一区 | 99久久电影 | 网站黄色在线免费观看 | 一级毛片,一级毛片 | 九九热免费看 | 特级丰满少妇一级aaaa爱毛片 | 久久精品屋 | 福利av在线 | 精品一区二区在线观看 | 久久69精品久久久久久久电影好 | 一级欧美日韩 | 免费福利视频一区二区三区 | 中文字幕日韩专区 | 五月婷婷婷 | 精品国产18久久久久久二百 | 国产三级一区二区三区 | 成人在线精品视频 | 亚洲av毛片成人精品 | 99这里只有精品视频 | 亚洲综合字幕 | 羞羞的视频在线观看 | 欧美国产精品一区二区三区 | 国产精品一区二区视频 | 91看片网| 国产aa | 尤物在线精品视频 | 国产乱人伦| 蜜桃av一区二区三区 | 九九九国产 | 成年人黄色一级毛片 | 免费在线观看一区二区 |