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

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

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

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

    1. 如何終止多處理池進程?

      How to terminate multiprocessing Pool processes?(如何終止多處理池進程?)

      <legend id='94yBz'><style id='94yBz'><dir id='94yBz'><q id='94yBz'></q></dir></style></legend>

      <small id='94yBz'></small><noframes id='94yBz'>

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

          <tbody id='94yBz'></tbody>

          <bdo id='94yBz'></bdo><ul id='94yBz'></ul>
              1. 本文介紹了如何終止多處理池進程?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我正在開發渲染農場,我需要我的客戶能夠啟動渲染器的多個實例,而不會阻塞,以便客戶端可以接收新命令.我的工作正常,但是在終止創建的進程時遇到問題.

                I'm working on a renderfarm, and I need my clients to be able to launch multiple instances of a renderer, without blocking so the client can receive new commands. I've got that working correctly, however I'm having trouble terminating the created processes.

                在全局級別,我定義了我的池(以便我可以從任何函數訪問它):

                At the global level, I define my pool (so that I can access it from any function):

                p = Pool(2)
                

                然后我用 apply_async 調用我的渲染器:

                I then call my renderer with apply_async:

                for i in range(totalInstances):
                    p.apply_async(render, (allRenderArgs[i],args[2]), callback=renderFinished)
                p.close()
                

                該函數完成,在后臺啟動進程,并等待新命令.我做了一個簡單的命令,它將殺死客戶端并停止渲染:

                That function finishes, launches the processes in the background, and waits for new commands. I've made a simple command that will kill the client and stop the renders:

                def close():
                    '''
                        close this client instance
                    '''
                    tn.write ("say "+USER+" is leaving the farm
                ")
                    try:
                        p.terminate()
                    except Exception,e:
                        print str(e)
                        sys.exit()
                

                它似乎沒有給出錯誤(它會打印錯誤),python 終止但后臺進程仍在運行.誰能推薦一種更好的方法來控制這些已啟動的程序?

                It doesn't seem to give an error (it would print the error), the python terminates but the background processes are still running. Can anyone recommend a better way of controlling these launched programs?

                推薦答案

                找到了我自己問題的答案.主要問題是我調用的是第三方應用程序而不是函數.當我調用子進程[使用 call() 或 Popen()] 時,它會創建一個新的 python 實例,其唯一目的是調用新的應用程序.但是當 python 退出時,它會殺死這個新的 python 實例并讓應用程序繼續運行.

                Found the answer to my own question. The primary problem was that I was calling a third-party application rather than a function. When I call the subprocess [either using call() or Popen()] it creates a new instance of python whose only purpose is to call the new application. However when python exits, it will kill this new instance of python and leave the application running.

                解決方案是通過找到所創建的 python 進程的 pid,獲取該 pid 的子進程并殺死它們來執行此操作.此代碼特定于 osx;有更簡單的代碼(不依賴于 grep)可用于 linux.

                The solution is to do it the hard way, by finding the pid of the python process that is created, getting the children of that pid, and killing them. This code is specific for osx; there is simpler code (that doesn't rely on grep) available for linux.

                for process in pool:
                    processId = process.pid
                    print "attempting to terminate "+str(processId)
                    command = " ps -o pid,ppid -ax | grep "+str(processId)+" | cut -f 1 -d " " | tail -1"
                    ps_command = Popen(command, shell=True, stdout=PIPE)
                    ps_output = ps_command.stdout.read()
                    retcode = ps_command.wait()
                    assert retcode == 0, "ps command returned %d" % retcode
                    print "child process pid: "+ str(ps_output)
                    os.kill(int(ps_output), signal.SIGTERM)
                    os.kill(int(processId), signal.SIGTERM)
                

                這篇關于如何終止多處理池進程?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='fkvNz'></bdo><ul id='fkvNz'></ul>
                        <tbody id='fkvNz'></tbody>

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

                        <i id='fkvNz'><tr id='fkvNz'><dt id='fkvNz'><q id='fkvNz'><span id='fkvNz'><b id='fkvNz'><form id='fkvNz'><ins id='fkvNz'></ins><ul id='fkvNz'></ul><sub id='fkvNz'></sub></form><legend id='fkvNz'></legend><bdo id='fkvNz'><pre id='fkvNz'><center id='fkvNz'></center></pre></bdo></b><th id='fkvNz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='fkvNz'><tfoot id='fkvNz'></tfoot><dl id='fkvNz'><fieldset id='fkvNz'></fieldset></dl></div>
                        <tfoot id='fkvNz'></tfoot>
                      1. <legend id='fkvNz'><style id='fkvNz'><dir id='fkvNz'><q id='fkvNz'></q></dir></style></legend>
                        • 主站蜘蛛池模板: 免费成人毛片 | 国产精品1区2区 | 日韩免费看片 | 欧美一级毛片免费观看 | 大学生a级毛片免费视频 | 国产一区二区 | 一区中文字幕 | 亚洲国产成人精品一区二区 | 在线播放亚洲 | 日本一区二区在线视频 | 国产日产精品一区二区三区四区 | 伊人看片 | 2018中文字幕第一页 | 日韩av在线免费 | 日韩免费在线视频 | 久久一| 精品一区av | 久久久蜜臀国产一区二区 | 久久精品免费一区二区 | 99久热在线精品视频观看 | 久久久久久国产精品免费 | 国产精品高清在线 | 一区二区视屏 | 欧美日韩不卡 | 欧美激情精品久久久久 | aⅴ色国产 欧美 | 伊人狠狠操 | 一区二区三区在线观看免费视频 | 日本理论片好看理论片 | 激情欧美日韩一区二区 | 成人在线免费电影 | 日韩欧美国产一区二区三区 | 国产在线精品一区二区 | 国产高清视频在线 | 国产激情自拍视频 | 在线视频 亚洲 | 欧美一区二区三区 | 久久国产区 | 日韩在线精品视频 | 国产亚洲精品久久yy50 | 亚洲三区在线 |