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

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

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

      <i id='XfZBF'><tr id='XfZBF'><dt id='XfZBF'><q id='XfZBF'><span id='XfZBF'><b id='XfZBF'><form id='XfZBF'><ins id='XfZBF'></ins><ul id='XfZBF'></ul><sub id='XfZBF'></sub></form><legend id='XfZBF'></legend><bdo id='XfZBF'><pre id='XfZBF'><center id='XfZBF'></center></pre></bdo></b><th id='XfZBF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XfZBF'><tfoot id='XfZBF'></tfoot><dl id='XfZBF'><fieldset id='XfZBF'></fieldset></dl></div>
    1. <tfoot id='XfZBF'></tfoot>
      1. 將 Python Twisted 與多處理混合使用?

        Mix Python Twisted with multiprocessing?(將 Python Twisted 與多處理混合使用?)

                <tbody id='kVJDr'></tbody>

            1. <small id='kVJDr'></small><noframes id='kVJDr'>

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

                <i id='kVJDr'><tr id='kVJDr'><dt id='kVJDr'><q id='kVJDr'><span id='kVJDr'><b id='kVJDr'><form id='kVJDr'><ins id='kVJDr'></ins><ul id='kVJDr'></ul><sub id='kVJDr'></sub></form><legend id='kVJDr'></legend><bdo id='kVJDr'><pre id='kVJDr'><center id='kVJDr'></center></pre></bdo></b><th id='kVJDr'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='kVJDr'><tfoot id='kVJDr'></tfoot><dl id='kVJDr'><fieldset id='kVJDr'></fieldset></dl></div>
                <legend id='kVJDr'><style id='kVJDr'><dir id='kVJDr'><q id='kVJDr'></q></dir></style></legend>
                • <tfoot id='kVJDr'></tfoot>
                  本文介紹了將 Python Twisted 與多處理混合使用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我需要用 Python 編寫一個類似代理的程序,工作流程與 Web 代理非常相似.該程序位于客戶端和服務器之間,接收客戶端向服務器發送的請求,處理請求,然后將其發送到原始服務器.當然使用的協議是私有協議,使用TCP.

                  I need to write a proxy like program in Python, the work flow is very similar to a web proxy. The program sits in between the client and the server, incept requests sent by the client to the server, process the request, then send it to the original server. Of course the protocol used is a private protocol uses TCP.

                  為了盡量減少工作量,我想使用 Python Twisted 來處理請求接收(部分充當服務器)和重新發送(部分充當客戶端).

                  To minimize the effort, I want to use Python Twisted to handle the request receiving (the part acts as a server) and resending (the part acts as a client).

                  為了最大化性能,我想使用 python 多處理(線程有 GIL 限制)將程序分成三個部分(進程).第一個進程運行 Twisted 接收請求,將請求放入隊列,并立即向原始客戶端返回成功.第二個進程從隊列中獲取請求,進一步處理請求并將其放入另一個隊列.第三個進程從第二個隊列中獲取請求并將其發送到原始服務器.

                  To maximum the performance, I want to use python multiprocessing (threading has the GIL limit) to separate the program into three parts (processes). The first process runs Twisted to receive requests, put the request in a queue, and return success immediately to the original client. The second process take request from the queue, process the request further and put it to another queue. The 3rd process take request from the 2nd queue and send it to the original server.

                  我是 Python Twisted 的新手,我知道它是事件驅動的,我還聽說最好不要將 Twisted 與線程或多處理混合使用.所以我不知道這種方式是否合適或者僅使用Twisted是否有更優雅的方式?

                  I was a new comer to Python Twisted, I know it is event driven, I also heard it's better to not mix Twisted with threading or multiprocessing. So I don't know whether this way is appropriate or is there a more elegant way by just using Twisted?

                  推薦答案

                  Twisted 有自己的事件驅動運行子進程的方式(在我的謙虛但正確的觀點中)比 multiprocessing 模塊.核心 API 是 spawnProcess,但是像 ampoule 提供更高級別的包裝器.

                  Twisted has its own event-driven way of running subprocesses which is (in my humble, but correct, opinion) better than the multiprocessing module. The core API is spawnProcess, but tools like ampoule provide higher-level wrappers over it.

                  如果您使用 spawnProcess,您將能夠像處理 Twisted 中的任何其他事件一樣處理子流程的輸出;如果你使用multiprocessing,你需要開發你自己的基于隊列的方法,以某種方式從子進程獲取輸出到Twisted mainloop,因為正常的callFromThread 線程可能使用的 API 在另一個進程中不起作用.根據你如何稱呼它,它要么嘗試腌制反應器,要么只是在子進程中使用不同的非工作反應器;無論哪種方式,它都會永遠失去你的電話.

                  If you use spawnProcess, you will be able to handle output from subprocesses in the same way you'd handle any other event in Twisted; if you use multiprocessing, you'll need to develop your own queue-based way of getting output from a subprocess into the Twisted mainloop somehow, since the normal callFromThread API that a thread might use won't work from another process. Depending on how you call it, it will either try to pickle the reactor, or just use a different non-working reactor in the subprocess; either way it will lose your call forever.

                  這篇關于將 Python Twisted 與多處理混合使用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)

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

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

                            <tbody id='lcxHI'></tbody>
                        1. <legend id='lcxHI'><style id='lcxHI'><dir id='lcxHI'><q id='lcxHI'></q></dir></style></legend>

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

                          • 主站蜘蛛池模板: 日产精品久久久一区二区 | 九九色影院 | 黄色免费片 | 少妇特黄a一区二区三区 | 欧美专区第一页 | 日本色视频 | 中文有码在线 | 色综合天天综合网国产成人网 | 亚洲91av| 91久久精品日日躁夜夜躁欧美 | 国产免费无遮挡 | 亚洲成a人 | 一本色道久久综合亚洲精品酒店 | 人人干人人看 | www.av在线播放| 国产在线一区二区三区 | 日韩成人精品 | 99国产免费 | 黄色影音| 亚洲天堂视频在线 | 亚洲精品久久久久avwww潮水 | 欧美日韩色| 久久av红桃一区二区小说 | 欧美视频在线一区 | 性生活网址 | 亚洲精品免费观看 | www.av在线| 久久久久久久成人 | 看一级黄色片 | 免费的黄色小视频 | 日本国产在线观看 | av第一页| 一级黄片毛片 | 免费国产黄色 | 日韩伦理视频 | 黄色片视频 | 天天操夜夜干 | 成人a毛片 | 91午夜理伦私人影院 | 天天爽天天爽 | 黄色一级毛片 |