久久久久久久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 - 從可執(zhí)行文件運(yùn)行時(shí),Multiprocessing.proces

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

          <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 - 從可執(zhí)行文件運(yùn)行時(shí),Multiprocessing.processes 成為主進(jìn)程的副本的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我剛剛在我的程序中發(fā)現(xiàn)了一個(gè)奇怪的錯(cuò)誤,它與它使用 Python 的多處理模塊有關(guān).當(dāng)我從機(jī)器上的源代碼運(yùn)行程序時(shí),一切正常.但是我一直在使用 pyinstaller 將它構(gòu)建成一個(gè)可執(zhí)行文件,并且由于某種原因,當(dāng)我運(yùn)行從我的代碼構(gòu)建的可執(zhí)行文件時(shí),多處理的行為發(fā)生了巨大的變化.具體來(lái)說(shuō),當(dāng)我嘗試運(yùn)行我的代碼的多處理部分時(shí),而不是做它應(yīng)該做的,似乎是我的程序主窗口的副本彈出,每個(gè)進(jìn)程一個(gè).更糟糕的是,如果手動(dòng)關(guān)閉它們,它們會(huì)重新打開,大概是因?yàn)樗鼈兪?multiprocessing.pool 的一部分.不打印任何錯(cuò)誤消息,并且一旦創(chuàng)建所有窗口就坐在那里什么都不做.是什么原因造成的?

                  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 嘗試通過(guò)啟動(dòng)新的實(shí)例來(lái)模擬 Unix fork() 系統(tǒng)調(diào)用您的可執(zhí)行文件,并在其中執(zhí)行其子進(jìn)程例程 (multiprocessing.forking.main()).使用標(biāo)準(zhǔn) Python 解釋器 (python.exe),multiprocessing 可以傳遞 -c 參數(shù)來(lái)運(yùn)行自定義代碼.但是,對(duì)于自定義可執(zhí)行文件,這是不可能的,因?yàn)榭蓤?zhí)行文件很可能不支持與 python.exe 相同的命令行選項(xiàng).

                  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() 函數(shù)通過(guò)顯式執(zhí)行子進(jìn)程例程來(lái)回避這個(gè)問(wèn)題,并通過(guò)調(diào)用 sys.exit() 終止解釋器.如果忘記調(diào)用freeze_support(),新進(jìn)程不知道自己是子進(jìn)程,運(yùn)行主應(yīng)用邏輯.在您的情況下,這將彈出另一個(gè)主 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.

                  由于從新創(chuàng)建的進(jìn)程啟動(dòng)另一個(gè)子進(jìn)程將導(dǎo)致無(wú)限遞歸,multiprocessing 試圖通過(guò)檢查 sys.frozen 屬性并引發(fā) RuntimeError 如果 freeze_support() 未被調(diào)用.在您的情況下,似乎需要用戶交互來(lái)生成進(jìn)程,因此沒(méi)有無(wú)限遞歸,也沒(méi)有 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 僅設(shè)置為由 py2exe 或 PyInstaller 創(chuàng)建的自動(dòng)生成的可執(zhí)行文件.當(dāng)您想要將 Python 嵌入到應(yīng)支持 windows 下的多處理的自定義可執(zhí)行文件中時(shí),了解此邏輯并將 sys.frozen 設(shè)置為 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.

                  這篇關(guān)于Python - 從可執(zhí)行文件運(yùn)行時(shí),Multiprocessing.processes 成為主進(jìn)程的副本的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動(dòng)后進(jìn)度躍升至 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 刻度標(biāo)簽設(shè)置在固定位置,以便當(dāng)我向左或向右滾動(dòng)時(shí),yaxis 刻度標(biāo)簽應(yīng)該可見(jiàn)
                  `QImage` constructor has unknown keyword `data`(`QImage` 構(gòu)造函數(shù)有未知關(guān)鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時(shí)顯示進(jìn)度條?)

                  <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'>

                          • 主站蜘蛛池模板: 黑人精品xxx一区一二区 | 91精品国产91久久久久游泳池 | 国产女人第一次做爰毛片 | 国产91丝袜在线播放 | 亚洲成人中文字幕 | 国产激情偷乱视频一区二区三区 | 欧美日韩综合 | 亚洲一区中文字幕在线观看 | 国产探花在线精品一区二区 | 国产美女在线播放 | 黄色片在线免费看 | 天天色综| 午夜丰满少妇一级毛片 | 男女网站免费观看 | 成人精品视频免费 | 亚洲欧美中文字幕在线观看 | 欧美在线不卡 | 亚洲精品视频网站在线观看 | 国产日韩欧美在线播放 | 久久精品美女 | 日韩中文字幕一区 | 成人精品免费视频 | 国产精品视频一二三区 | 99pao成人国产永久免费视频 | 久久精品成人 | 2一3sex性hd| 国产最新精品视频 | www.免费看片.com | 亚洲精品视频在线观看免费 | 国产色网 | 国产又色又爽又黄又免费 | 国精产品一区一区三区免费完 | 国产视频一区二区 | 国产乱码精品一品二品 | www.久久久.com | 日韩一级不卡 | 国产精品99久久久久久人 | 欧美激情精品久久久久久 | 97视频成人 | 免费看91 | 中文字幕乱码一区二区三区 |