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

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

    3. <tfoot id='SvNTA'></tfoot>

      • <bdo id='SvNTA'></bdo><ul id='SvNTA'></ul>

      Python multiprocessing.Queue 上的 put 和 get 死鎖

      Python multiprocessing.Queue deadlocks on put and get(Python multiprocessing.Queue 上的 put 和 get 死鎖)

            <legend id='dNfEZ'><style id='dNfEZ'><dir id='dNfEZ'><q id='dNfEZ'></q></dir></style></legend>

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

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

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

                  <tbody id='dNfEZ'></tbody>
                <tfoot id='dNfEZ'></tfoot>
                本文介紹了Python multiprocessing.Queue 上的 put 和 get 死鎖的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                這段代碼遇到了死鎖問題:

                I'm having deadlock problems with this piece of code:

                
                def _entropy_split_parallel(data_train, answers_train, weights):
                    CPUS = 1 #multiprocessing.cpu_count()
                    NUMBER_TASKS = len(data_train[0])
                    processes = []
                
                    multi_list = zip(data_train, answers_train, weights)
                
                    task_queue = multiprocessing.Queue()
                    done_queue = multiprocessing.Queue()
                
                    for feature_index in xrange(NUMBER_TASKS):
                        task_queue.put(feature_index)
                
                    for i in xrange(CPUS):
                        process = multiprocessing.Process(target=_worker, 
                                args=(multi_list, task_queue, done_queue))
                        processes.append(process)
                        process.start()
                
                    min_entropy = None
                    best_feature = None
                    best_split = None
                    for i in xrange(NUMBER_TASKS):
                        entropy, feature, split = done_queue.get()
                        if (entropy < min_entropy or min_entropy == None) and entropy != None:
                            best_feature = feature
                            best_split = split
                
                    for i in xrange(CPUS):
                        task_queue.put('STOP')
                
                    for process in processes:
                        process.join()
                
                    return best_feature, best_split
                
                
                def _worker(multi_list, task_queue, done_queue):
                    feature_index = task_queue.get()
                    while feature_index != 'STOP':
                        result = _entropy_split3(multi_list, feature_index)
                        done_queue.put(result)
                        feature_index = task_queue.get()
                

                當我運行我的程序時,它可以通過 _entropy_split_parallel 運行幾次,但最終會死鎖.父進程在 done_queue.get() 上阻塞,工作進程在 done_queue.put() 上阻塞.由于發(fā)生這種情況時隊列始終為空,因此預計會阻塞 get.我不明白為什么工作人員會阻塞 put,因為隊列顯然沒有滿(它是空的!).我試過 blocktimeout 關鍵字參數(shù),但得到相同的結果.

                When I run my program, it works fine for several runs through _entropy_split_parallel, but eventually deadlocks. The parent process is blocking on done_queue.get(), and the worker process is blocking on done_queue.put(). Since the queue is always empty when this happens, blocking on get is expected. What I don't understand is why the worker is blocking on put, since the queue is obviously not full (it's empty!). I've tried the block and timeout keyword arguments, but get the same result.

                我正在使用多處理反向端口,因為我堅持使用 Python 2.5.

                I'm using the multiprocessing backport, since I'm stuck with Python 2.5.

                看起來我也遇到了多處理模塊提供的示例之一的死鎖問題.這是 here. 底部的第三個示例.如果我調用多次測試方法.例如,將腳本底部更改為:

                It looks like I'm also getting deadlock issues with one of the examples provided with the multiprocessing module. It's the third example from the bottom here. The deadlocking only seems to occur if I call the test method many times. For example, changing the bottom of the script to this:

                
                if __name__ == '__main__':
                    freeze_support()
                    for x in xrange(1000):
                        test()
                

                <小時>

                我知道這是一個老問題,但測試表明這在使用 Python 2.7 的 Windows 上不再是問題.我將嘗試 Linux 并報告.


                I know this is an old question, but testing shows that this is no longer a problem on windows with Python 2.7. I will try Linux and report back.

                推薦答案

                這個問題在 Python 的新版本中消失了,所以我假設它是 backport 的問題.無論如何,這不再是問題.

                This problem went away with newer versions of Python, so I'm assuming it was a problem with the backport. Anyways, it's no longer an issue.

                這篇關于Python multiprocessing.Queue 上的 put 和 get 死鎖的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關文檔推薦

                How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 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` 構造函數(shù)有未知關鍵字 `data`)
                Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)
                  <bdo id='2XfE9'></bdo><ul id='2XfE9'></ul>

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

                          <tbody id='2XfE9'></tbody>

                        1. <tfoot id='2XfE9'></tfoot>
                          <legend id='2XfE9'><style id='2XfE9'><dir id='2XfE9'><q id='2XfE9'></q></dir></style></legend>
                        2. 主站蜘蛛池模板: 欧美日韩久久精品 | 日韩精品成人免费观看视频 | 国产精品久久久久aaaa樱花 | 老司机成人在线 | 国产伦精品 | 日韩网站在线 | 欧美激情综合 | 羞羞视频网 | 一级毛片观看 | 成人在线一区二区 | 国产极品车模吞精高潮呻吟 | 精品久久99 | 99久热在线精品视频观看 | 日韩精品视频一区二区三区 | 色香蕉在线 | 欧美一区二区三区一在线观看 | 国产特级毛片aaaaaa | 蜜臀网 | 欧美精品在线观看 | 日韩图区 | 日韩欧美一区二区三区四区 | 成人精品视频免费 | 久久99精品久久久久久噜噜 | 国产精品激情在线 | 国产小视频在线 | www.一级片 | 看片wwwwwwwwwww | 天天拍天天射 | 91九色在线观看 | 亚洲交性| 欧美激情在线精品一区二区三区 | 国产黑丝av | 日本二区在线观看 | 毛片一级黄色 | av中文字幕在线观看 | 国产精品永久免费观看 | 国产精品一区二区三区四区 | 欧美成人手机在线 | 国产精品久久久爽爽爽麻豆色哟哟 | 五月槐花香| 亚洲福利在线观看 |