久久久久久久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中控制用于調用外部命令的子進程數

      Control the number of subprocesses using to call external commands in python(在python中控制用于調用外部命令的子進程數)
    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中控制用于調用外部命令的子進程數的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我了解使用 subprocess 是調用外部命令的首選方式.

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

                但是,如果我想并行運行多個命令,但要限制生成的進程數怎么辦?困擾我的是我無法阻止子進程.例如,如果我調用

                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)
                

                然后該過程將繼續,無需等待 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];
                

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

                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.

                限制子進程數量的正確方法是什么?

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

                推薦答案

                如果要等待命令完成,可以使用subprocess.call.有關詳細信息,請參閱 pydoc 子進程.

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

                您也可以調用 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()
                

                這篇關于在python中控制用于調用外部命令的子進程數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                Passing multiple parameters to pool.map() function in Python(在 Python 中將多個參數傳遞給 pool.map() 函數)
                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 多進程池.當其中一個工作進程確定不再需要完成工作時,如何退出腳本?) - IT屋-程序員
                How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊列引用傳遞給 pool.map_async() 管理的函數?)
                yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯誤的另一個混淆,“模塊對象沒有屬性“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'>

                          主站蜘蛛池模板: 久久久久久看片 | 视频在线一区二区 | 久久精品亚洲 | 国产97色| 日韩精品在线一区 | av大片| 国产欧美性成人精品午夜 | 黄色在线网站 | 中文字幕日韩欧美 | 人人插人人 | 成人免费视屏 | 国产精品96久久久久久 | 天天草天天操 | 超碰人人人人 | 99成人 | 日韩在线播放第一页 | 成人av网站在线观看 | 免费国产一区二区 | 精品欧美一区二区三区免费观看 | 一区二区三区免费 | 久久久精品一区 | 91免费观看国产 | 日韩视频精品 | 免费观看成人鲁鲁鲁鲁鲁视频 | www.日韩av.com| 国产精品视频一区二区三区不卡 | 天天干人人 | 亚洲一区二区三区在线视频 | 久久久国产一区二区三区 | 亚洲福利一区 | 在线观看中文字幕 | 久操亚洲 | 一区二区三区亚洲视频 | 91在线一区二区三区 | 91成人精品 | www.免费看片.com | 亚洲一区二区三区在线视频 | 精品1区2区| 亚洲美女av网站 | 亚洲成人自拍 | 亚洲视频三区 |