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

<tfoot id='LBmZJ'></tfoot>

    1. <small id='LBmZJ'></small><noframes id='LBmZJ'>

        <bdo id='LBmZJ'></bdo><ul id='LBmZJ'></ul>

    2. <i id='LBmZJ'><tr id='LBmZJ'><dt id='LBmZJ'><q id='LBmZJ'><span id='LBmZJ'><b id='LBmZJ'><form id='LBmZJ'><ins id='LBmZJ'></ins><ul id='LBmZJ'></ul><sub id='LBmZJ'></sub></form><legend id='LBmZJ'></legend><bdo id='LBmZJ'><pre id='LBmZJ'><center id='LBmZJ'></center></pre></bdo></b><th id='LBmZJ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='LBmZJ'><tfoot id='LBmZJ'></tfoot><dl id='LBmZJ'><fieldset id='LBmZJ'></fieldset></dl></div>
      <legend id='LBmZJ'><style id='LBmZJ'><dir id='LBmZJ'><q id='LBmZJ'></q></dir></style></legend>
    3. 在python中控制用于調(diào)用外部命令的子進(jìn)程數(shù)

      Control the number of subprocesses using to call external commands in python(在python中控制用于調(diào)用外部命令的子進(jìn)程數(shù))
    4. <legend id='I99ng'><style id='I99ng'><dir id='I99ng'><q id='I99ng'></q></dir></style></legend>

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

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

                <tbody id='I99ng'></tbody>

                本文介紹了在python中控制用于調(diào)用外部命令的子進(jìn)程數(shù)的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                限時(shí)送ChatGPT賬號(hào)..

                我了解使用 subprocess 是調(diào)用外部命令的首選方式.

                I understand using subprocess is the preferred way of calling external command.

                但是,如果我想并行運(yùn)行多個(gè)命令,但要限制生成的進(jìn)程數(shù)怎么辦?困擾我的是我無法阻止子進(jìn)程.例如,如果我調(diào)用

                But what if I want to run several commands in parall, but limit the number of processes being spawned? What bothers me is that I can't block the subprocesses. For example, if I call

                subprocess.Popen(cmd, stderr=outputfile, stdout=outputfile)
                

                然后該過程將繼續(xù),無需等待 cmd 完成.因此,我無法將其包裝在 multiprocessing 庫的工作人員中.

                Then the process will continue, without waiting for cmd to finish. Therefore, I can't wrap it up in a worker of multiprocessing library.

                例如,如果我這樣做:

                def worker(cmd): 
                    subprocess.Popen(cmd, stderr=outputfile, stdout=outputfile);
                
                pool = Pool( processes = 10 );
                results =[pool.apply_async(worker, [cmd]) for cmd in cmd_list];
                ans = [res.get() for res in results];
                

                然后每個(gè)工作人員將在生成子進(jìn)程后完成并返回.所以我不能通過使用Pool 來真正限制subprocess 生成的進(jìn)程數(shù).

                then each worker will finish and return after spawning a subprocess. So I can't really limit the number of processes generated by subprocess by using Pool.

                限制子進(jìn)程數(shù)量的正確方法是什么?

                What's the proper way of limiting the number of subprocesses?

                推薦答案

                如果要等待命令完成,可以使用subprocess.call.有關(guān)詳細(xì)信息,請參閱 pydoc 子進(jìn)程.

                You can use subprocess.call if you want to wait for the command to complete. See pydoc subprocess for more information.

                您也可以調(diào)用 Popen.wait 你的工人中的方法:

                You could also call the Popen.wait method in your worker:

                def worker(cmd): 
                    p = subprocess.Popen(cmd, stderr=outputfile, stdout=outputfile);
                    p.wait()
                

                這篇關(guān)于在python中控制用于調(diào)用外部命令的子進(jìn)程數(shù)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                Passing multiple parameters to pool.map() function in Python(在 Python 中將多個(gè)參數(shù)傳遞給 pool.map() 函數(shù))
                multiprocessing.pool.MaybeEncodingError: #39;TypeError(quot;cannot serialize #39;_io.BufferedReader#39; objectquot;,)#39;(multiprocessing.pool.MaybeEncodingError: TypeError(cannot serialize _io.BufferedReader object,)) - IT屋-程序員軟件開
                Python Multiprocess Pool. How to exit the script when one of the worker process determines no more work needs to be done?(Python 多進(jìn)程池.當(dāng)其中一個(gè)工作進(jìn)程確定不再需要完成工作時(shí),如何退出腳本?) - IT屋-程序員
                How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊(duì)列引用傳遞給 pool.map_async() 管理的函數(shù)?)
                yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯(cuò)誤的另一個(gè)混淆,“模塊對象沒有屬性“f)
                    <bdo id='akyse'></bdo><ul id='akyse'></ul>

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

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

                          主站蜘蛛池模板: 午夜在线观看免费视频 | 欧美一区二区三区视频 | 国产中文一区 | 欧美福利在线观看 | 亚洲一区二区在线视频 | 国产黄色在线播放 | 色网站在线 | 婷婷久久综合 | 欧美xxxx性 | 久久91 | 亚洲激情视频在线 | 国产h视频在线观看 | 97福利视频 | 国产成人精品一区二区三区四区 | 亚洲激情视频在线观看 | 久久黄色大片 | 国产极品在线观看 | 成人午夜视频在线观看 | 欧美三级在线视频 | 狠狠综合网 | 六月丁香激情 | 久久观看 | 国产一区二区网站 | 午夜视频免费在线观看 | 亚洲乱码在线 | 黄色直接看 | 操碰在线视频 | 一区在线视频 | 国产精品久久久久久久久免费桃花 | 午夜专区| aaa成人 | 国产又黄又粗 | 国产三级在线 | 超碰免费在线 | 国产精品福利视频 | 欧美亚洲一区二区三区 | 免费网站观看www在线观看 | 欧美一区在线视频 | 精品一区二区三区视频 | 日韩手机看片 | 日韩欧美视频 |