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

        在子進(jìn)程已經(jīng)啟動后授予對共享內(nèi)存的訪問權(quán)限

        Giving access to shared memory after child processes have already started(在子進(jìn)程已經(jīng)啟動后授予對共享內(nèi)存的訪問權(quán)限)

        <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>
                  本文介紹了在子進(jìn)程已經(jīng)啟動后授予對共享內(nèi)存的訪問權(quán)限的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

                  如果數(shù)據(jù)僅在子進(jìn)程生成后可用(使用 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,但我不知道如何讓我的子進(jìn)程訪問在進(jìn)程已經(jīng)啟動后創(chuàng)建的 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.

                  數(shù)據(jù)由父進(jìn)程生成,數(shù)據(jù)量事先不知道.

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

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

                  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 內(nèi)存.

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

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

                  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() 的調(diào)用者是父進(jìn)程而不是子進(jìn)程.

                  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.

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

                  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.

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

                  See this answer for details and an example.

                  推薦答案

                  您的問題聽起來非常適合 posix_ipcsysv_ipc 模塊,它們公開用于共享內(nèi)存、信號量和消息隊列的 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) 區(qū)域的問題在于,您無法輕松地與其他進(jìn)程共享它們——如果它們是文件支持的,這很容易,但如果您不這樣做實際上需要文件來做其他事情,感覺很傻.您可以clone(2) 系統(tǒng)調(diào)用中使用 CLONE_VM 標(biāo)志,如果這是在 C 中,但我不想嘗試使用它帶有一個可能對內(nèi)存安全做出假設(shè)的語言解釋器.(即使在 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 共享內(nèi)存映射甚至允許不相關(guān)的進(jìn)程通過標(biāo)識符附加和分離共享內(nèi)存,因此您需要做的就是與使用映射的進(jìn)程共享創(chuàng)建映射的進(jìn)程的標(biāo)識符,然后當(dāng)您在映射中操作數(shù)據(jù)時,它們可同時供所有進(jìn)程使用,而無需任何額外的解析開銷.shm_open(3) 函數(shù)返回一個 int,在以后調(diào)用 ftruncate(2) 時用作文件描述符mmap(2),因此其他進(jìn)程可以使用共享內(nèi)存段,而無需在文件系統(tǒng)中創(chuàng)建文件——即使使用它的所有進(jìn)程都已退出,該內(nèi)存仍將持續(xù)存在.(對于 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.)

                  這篇關(guān)于在子進(jìn)程已經(jīng)啟動后授予對共享內(nèi)存的訪問權(quán)限的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                  Passing multiple parameters to pool.map() function in Python(在 Python 中將多個參數(shù)傳遞給 pool.map() 函數(shù))
                  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 多進(jìn)程池.當(dāng)其中一個工作進(jìn)程確定不再需要完成工作時,如何退出腳本?) - IT屋-程序員
                  How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊列引用傳遞給 pool.map_async() 管理的函數(shù)?)
                  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>
                          • 主站蜘蛛池模板: 久久中文字幕一区 | 日韩视频中文字幕 | 福利久久| 在线欧美视频 | 黄色三级在线播放 | 欧美日韩中文字幕 | 91精品国产色综合久久 | 久久最新 | 精品久久久久一区二区国产 | 天堂色 | 亚洲精品在线播放 | 亚洲欧美少妇 | 日韩免费福利视频 | 婷婷色国产偷v国产偷v小说 | 国内精品久久久久 | 美女福利视频网站 | 日本a∨视频 | 日本在线视频一区二区 | 可以免费看的毛片 | 日日日操 | 亚洲国产精品久久久 | 国产精品极品美女在线观看免费 | 久久亚洲美女 | 欧美一级片久久 | 欧美日韩在线视频观看 | 亚洲另类自拍 | www亚洲一区| 久久中文字幕一区 | 精品国产乱码久久久久久丨区2区 | 亚洲国产精品一区二区第一页 | 成人毛片视频免费 | 国产一区二区免费 | 欧美专区在线观看 | 日韩一二区在线 | 二区三区av| 狠狠操av | 精品久久久久久久久久久久 | 国产精品成人在线 | 中文字幕在线观看日韩 | 中文字幕动漫成人 | 91资源在线|