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

  • <tfoot id='Yvunk'></tfoot>
      <bdo id='Yvunk'></bdo><ul id='Yvunk'></ul>

  • <small id='Yvunk'></small><noframes id='Yvunk'>

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

        Python - 從可執行文件運行時,Multiprocessing.proces

        Python - Multiprocessing.processes become copies of the main process when run from executable(Python - 從可執行文件運行時,Multiprocessing.processes 成為主進程的副本)

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

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

            <tfoot id='uEnkO'></tfoot>
            <legend id='uEnkO'><style id='uEnkO'><dir id='uEnkO'><q id='uEnkO'></q></dir></style></legend>
                • <bdo id='uEnkO'></bdo><ul id='uEnkO'></ul>
                    <tbody id='uEnkO'></tbody>
                  本文介紹了Python - 從可執行文件運行時,Multiprocessing.processes 成為主進程的副本的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我剛剛在我的程序中發現了一個奇怪的錯誤,它與它使用 Python 的多處理模塊有關.當我從機器上的源代碼運行程序時,一切正常.但是我一直在使用 pyinstaller 將它構建成一個可執行文件,并且由于某種原因,當我運行從我的代碼構建的可執行文件時,多處理的行為發生了巨大的變化.具體來說,當我嘗試運行我的代碼的多處理部分時,而不是做它應該做的,似乎是我的程序主窗口的副本彈出,每個進程一個.更糟糕的是,如果手動關閉它們,它們會重新打開,大概是因為它們是 multiprocessing.pool 的一部分.不打印任何錯誤消息,并且一旦創建所有窗口就坐在那里什么都不做.是什么原因造成的?

                  I just discovered a bizarre bug in my program related to its use of Python's multiprocessing module. Everything works fine when I run the program from the source on my machine. But I've been building it into an executable using pyinstaller, and for some reason the behavior of multiprocessing changes drastically when I run the executable built from my code. Specifically, when I try to run the multiprocessing part of my code, rather than do what it's supposed to, what appears to be a copy of my program's main window pops up, one for each process. Even worse, they reopen if they are closed manually, presumably because they are part of a multiprocessing.pool. No error messages are printed, and once created all the windows just sit there doing nothing. What could be happening to cause this?

                  推薦答案

                  在 Windows 上,multiprocessing 嘗試通過啟動新的實例來模擬 Unix fork() 系統調用您的可執行文件,并在其中執行其子進程例程 (multiprocessing.forking.main()).使用標準 Python 解釋器 (python.exe),multiprocessing 可以傳遞 -c 參數來運行自定義代碼.但是,對于自定義可執行文件,這是不可能的,因為可執行文件很可能不支持與 python.exe 相同的命令行選項.

                  On Windows, multiprocessing tries to emulate the Unix fork() system call by starting new instances of your executable, and execute its child process routine (multiprocessing.forking.main()) therein. With the standard Python interpreter (python.exe), multiprocessing can pass the -c parameter to run custom code. For custom executables, however, this is not be possible since the executable will most probably not support the same command line options as python.exe.

                  freeze_support() 函數通過顯式執行子進程例程來回避這個問題,并通過調用 sys.exit() 終止解釋器.如果忘記調用freeze_support(),新進程不知道自己是子進程,運行主應用邏輯.在您的情況下,這將彈出另一個主 GUI 窗口.

                  The freeze_support() function sidesteps this problem by executing the child process routine explicitely, and terminate the interpreter by calling sys.exit(). If you forget to call freeze_support(), the new process does not know that it is a child process and runs the main application logic. In your case, this will pop up another main GUI window.

                  由于從新創建的進程啟動另一個子進程將導致無限遞歸,multiprocessing 試圖通過檢查 sys.frozen 屬性并引發 RuntimeError 如果 freeze_support() 未被調用.在您的情況下,似乎需要用戶交互來生成進程,因此沒有無限遞歸,也沒有 RuntimeError.

                  Since starting yet another child process from the newly created process will cause infinite recursion, multiprocessing tries to prevent this by checking the sys.frozen attribute and raise a RuntimeError if freeze_support() was not called. In your case, it seems that user interaction is required to spawn the processes, therefore there is no infinite recursion and no RuntimeError.

                  按照慣例,sys.frozen 僅設置為由 py2exe 或 PyInstaller 創建的自動生成的可執行文件.當您想要將 Python 嵌入到應支持 windows 下的多處理的自定義可執行文件中時,了解此邏輯并將 sys.frozen 設置為 True 非常重要.

                  By convention, sys.frozen is only set for automatically generated executables as created by py2exe or PyInstaller. It is important to understand this logic and set sys.frozen to True when one wants to embed Python in a custom executable that should support multiprocessing under windows.

                  這篇關于Python - 從可執行文件運行時,Multiprocessing.processes 成為主進程的副本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

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

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

                            <tbody id='7bqw7'></tbody>
                            <bdo id='7bqw7'></bdo><ul id='7bqw7'></ul>
                          • <tfoot id='7bqw7'></tfoot>

                            <small id='7bqw7'></small><noframes id='7bqw7'>

                          • 主站蜘蛛池模板: 精品视频一区二区三区 | 久久久国产一区二区三区四区小说 | 国产高清一二三区 | 亚洲精品久久国产高清情趣图文 | 91在线成人 | 国产成人免费网站 | 成人1区2区| 亚洲成人一区二区在线 | 国产精品欧美一区二区三区 | 亚洲一区中文 | 国内精品在线视频 | 国产欧美日韩在线观看 | 国产精品国产精品 | 国产成人精品一区二区三区在线 | 羞羞视频网站免费观看 | 久久免费观看视频 | 日韩免费一二三区 | 精品99在线| 99热碰| 日本国产一区二区 | 精品av久久久久电影 | 国产在线观看网站 | 四虎精品在线 | 色婷婷综合久久久中字幕精品久久 | av播播| 亚洲欧美日韩精品久久亚洲区 | 狠狠操婷婷 | 日本在线看 | 一级欧美| www.蜜桃av | 国产一区不卡 | 久久久99国产精品免费 | 亚洲国产成人av好男人在线观看 | 嫩草视频网| 精品欧美乱码久久久久久 | 91在线视频播放 | 日韩视频一区二区三区 | 久久久久久久久久久久亚洲 | 成人日韩av | 福利片在线观看 | 99在线资源|