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

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

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

      <tfoot id='LOWuz'></tfoot>

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

        在子進程已經啟動后授予對共享內存的訪問權限

        Giving access to shared memory after child processes have already started(在子進程已經啟動后授予對共享內存的訪問權限)

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

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

                • <tfoot id='djNGL'></tfoot><legend id='djNGL'><style id='djNGL'><dir id='djNGL'><q id='djNGL'></q></dir></style></legend>
                  本文介紹了在子進程已經啟動后授予對共享內存的訪問權限的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  如果數據僅在子進程生成后可用(使用 multiprocessing.Process)?

                  How do I give child processes access to data in shared memory if the data is only available after the child processes have been spawned (using multiprocessing.Process)?

                  我知道 multiprocessing.sharedctypes.RawArray,但我不知道如何讓我的子進程訪問在進程已經啟動后創建的 RawArray .

                  I am aware of multiprocessing.sharedctypes.RawArray, but I can't figure out how to give my child processes access to a RawArray that is created after the processes have already started.

                  數據由父進程生成,數據量事先不知道.

                  The data is generated by the parent process, and the amount of data is not known in advance.

                  如果不是 GIL 我會使用線程來代替這將完成這項任務簡單一點.使用非 CPython 實現不是一種選擇.

                  If not for the GIL I'd be using threading instead which will make this task a little simpler. Using a non-CPython implementation is not an option.

                  查看 muliprocessing.sharedctypes,看起來共享 ctype 對象被分配了 使用 mmaped 內存.

                  Looking under the hood of muliprocessing.sharedctypes, it looks like shared ctype objects are allocated using mmaped memory.

                  所以這個問題真的可以歸結為:如果 mmap() 在子進程生成后被父進程調用,子進程能否訪問匿名映射的內存?

                  So this question really boils down to: Can a child process access an anonymously mapped memory if mmap() was called by the parent after the child process was spawned?

                  這有點像 this問題,除了在我的例子中 mmap() 的調用者是父進程而不是子進程.

                  That's somewhat in the vein of what's being asked in this question, except that in my case the caller of mmap() is the parent process and not the child process.

                  我創建了自己的 RawArray 版本,它在底層使用了 shm_open().只要標識符(tag)匹配,生成的共享 ctypes 數組就可以與任何進程共享.

                  I created my own version of RawArray that uses shm_open() under the hood. The resulting shared ctypes array can be shared with any process as long as the identifier (tag) matches.

                  請參閱此答案 了解詳細信息和示例.

                  See this answer for details and an example.

                  推薦答案

                  您的問題聽起來非常適合 posix_ipcsysv_ipc 模塊,它們公開用于共享內存、信號量和消息隊列的 POSIX 或 SysV API.那里的特征矩陣包括在他提供的模塊中挑選的極好的建議.

                  Your problem sounds like a perfect fit for the posix_ipc or sysv_ipc modules, which expose either the POSIX or SysV APIs for shared memory, semaphores, and message queues. The feature matrix there includes excellent advice for picking amongst the modules he provides.

                  匿名 mmap(2) 區域的問題在于,您無法輕松地與其他進程共享它們——如果它們是文件支持的,這很容易,但如果您不這樣做實際上需要文件來做其他事情,感覺很傻.您可以clone(2) 系統調用中使用 CLONE_VM 標志,如果這是在 C 中,但我不想嘗試使用它帶有一個可能對內存安全做出假設的語言解釋器.(即使在 C 語言中也會有點危險,因為五年后的維護程序員可能CLONE_VM 行為感到震驚.)

                  The problem with anonymous mmap(2) areas is that you cannot easily share them with other processes -- if they were file-backed, it'd be easy, but if you don't actually need the file for anything else, it feels silly. You could use the CLONE_VM flag to the clone(2) system call if this were in C, but I wouldn't want to try using it with a language interpreter that probably makes assumptions about memory safety. (It'd be a little dangerous even in C, as maintenance programmers five years from now might also be shocked by the CLONE_VM behavior.)

                  但是 SysV 和更新的 POSIX 共享內存映射甚至允許不相關的進程通過標識符附加和分離共享內存,因此您需要做的就是與使用映射的進程共享創建映射的進程的標識符,然后當您在映射中操作數據時,它們可同時供所有進程使用,而無需任何額外的解析開銷.shm_open(3) 函數返回一個 int,在以后調用 ftruncate(2) 時用作文件描述符mmap(2),因此其他進程可以使用共享內存段,而無需在文件系統中創建文件——即使使用它的所有進程都已退出,該內存仍將持續存在.(對于 Unix 來說可能有點奇怪,但它很靈活.)

                  But the SysV and newer POSIX shared memory mappings allow even unrelated processes to attach and detach from shared memory by identifier, so all you need to do is share the identifier from the processes that create the mappings with the processes that consume the mappings, and then when you manipulate data within the mappings, they are available to all processes simultaneously without any additional parsing overhead. The shm_open(3) function returns an int that is used as a file descriptor in later calls to ftruncate(2) and then mmap(2), so other processes can use the shared memory segment without a file being created in the filesystem -- and this memory will persist even if all processes using it have exited. (A little strange for Unix, perhaps, but it is flexible.)

                  這篇關于在子進程已經啟動后授予對共享內存的訪問權限的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='L0196'></bdo><ul id='L0196'></ul>
                    • <legend id='L0196'><style id='L0196'><dir id='L0196'><q id='L0196'></q></dir></style></legend>

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

                        <tbody id='L0196'></tbody>

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

                          • <tfoot id='L0196'></tfoot>
                          • 主站蜘蛛池模板: 一级片在线观看视频 | 色一情一乱一乱一区91av | 亚洲成人国产 | 福利视频二区 | 久久久午夜 | 欧美日韩激情 | 五月综合色 | 午夜视频在线播放 | 手机福利视频 | 中文字幕97 | av中文在线 | 日本三级视频在线观看 | 婷婷伊人网 | 在线a视频 | 深夜视频在线观看 | 蜜桃色999| 久久精品久久久 | 国产成人精品免费 | 日韩欧美国产精品 | 欧美又大粗又爽又黄大片视频 | 91精品国产一区二区三区 | 国产精品1区 | 日本三级大片 | 日韩爱爱视频 | 99国产精品99久久久久久粉嫩 | 啪啪高潮动态图 | 久久免费看片 | 五月婷视频 | 日韩成人精品一区二区 | 在线观看视频一区二区 | 国产一级二级 | 欧美一级淫片免费视频魅影视频 | 欧美精品成人 | 99热在线免费观看 | 日本久久精品视频 | 在线色综合 | 综合av | 欧美视频免费在线观看 | 欧美色综合天天久久综合精品 | 久久理论片| 亚洲精品一区二区三区蜜桃久 |