久久久久久久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. 多處理返回“打開(kāi)的文件太多";但是使用

        multiprocessing returns quot;too many open filesquot; but using `with...as` fixes it. Why?(多處理返回“打開(kāi)的文件太多;但是使用 `with...as` 可以解決這個(gè)問(wèn)題.為什么?)
          <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>

                  本文介紹了多處理返回“打開(kāi)的文件太多";但是使用 `with...as` 可以解決這個(gè)問(wèn)題.為什么?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我使用 this answer 以便在 Linux 機(jī)器上運(yùn)行 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)
                  

                  但是我收到了這個(gè)錯(cuò)誤:OSError: [Errno 24] Too many open files
                  因此,代碼打開(kāi)了太多的文件描述符,即:它啟動(dòng)了太多的進(jìn)程而沒(méi)有終止它們.

                  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.

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

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

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

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

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

                  with 下面發(fā)生了什么?

                  推薦答案

                  您正在循環(huán)中創(chuàng)建新進(jìn)程,然后在完成后忘記關(guān)閉它們.結(jié)果,您有太多打開(kāi)的進(jìn)程.這是個(gè)壞主意.

                  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.

                  您可以通過(guò)使用自動(dòng)調(diào)用 pool.terminate 的上下文管理器來(lái)解決此問(wèn)題,或者您自己手動(dòng)調(diào)用 pool.terminate.或者,你為什么不在循環(huán)外創(chuàng)建一個(gè)池一次,然后將任務(wù)發(fā)送到里面的進(jìn)程?

                  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
                  

                  有關(guān)更多信息,您可以仔細(xì)閱讀 multiprocessing.Pool 文檔.

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

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

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

                  相關(guān)文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動(dòng)后進(jìn)度躍升至 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 刻度標(biāo)簽設(shè)置在固定位置,以便當(dāng)我向左或向右滾動(dòng)時(shí),yaxis 刻度標(biāo)簽應(yīng)該可見(jiàn)
                  `QImage` constructor has unknown keyword `data`(`QImage` 構(gòu)造函數(shù)有未知關(guān)鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時(shí)顯示進(jìn)度條?)
                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>
                            主站蜘蛛池模板: 欧美性猛片aaaaaaa做受 | 日韩午夜 | 亚洲网站在线播放 | www国产成人免费观看视频,深夜成人网 | 欧美精品在线一区二区三区 | 激情久久网 | 精品久久久久久亚洲综合网 | 欧美精品三区 | 香蕉91| 欧美视频在线看 | 一区二区国产精品 | 亚洲精品一区二三区不卡 | 日韩福利视频 | 欧美日韩视频一区二区 | 精品中文在线 | 蜜臀久久 | 一本一道久久a久久精品蜜桃 | 北条麻妃一区二区三区在线观看 | 国产成人免费在线观看 | 中文字幕视频在线观看 | 亚洲精品视频久久 | 精品国产乱码久久久久久牛牛 | 亚洲日韩第一页 | 亚洲国产欧美一区二区三区久久 | 久久久久久国 | 欧美日韩久久精品 | 亚洲精品成人免费 | 欧美亚洲视频 | 黄色小视频大全 | 国产视频一区二区在线观看 | 91久久伊人 | 成人蜜桃av | 99精品视频免费在线观看 | 婷婷桃色网 | www.黄色片视频 | 欧美一级在线观看 | 天天综合日日夜夜 | 久久精品99| 乱一性一乱一交一视频a∨ 色爱av | 成人免费视频网站 | 亚州中文字幕 |