久久久久久久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 與多處理混合使用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我需要用 Python 編寫一個類似代理的程序,工作流程與 Web 代理非常相似.該程序位于客戶端和服務(wù)器之間,接收客戶端向服務(wù)器發(fā)送的請求,處理請求,然后將其發(fā)送到原始服務(wù)器.當(dāng)然使用的協(xié)議是私有協(xié)議,使用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 來處理請求接收(部分充當(dāng)服務(wù)器)和重新發(fā)送(部分充當(dāng)客戶端).

                  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 限制)將程序分成三個部分(進(jìn)程).第一個進(jìn)程運(yùn)行 Twisted 接收請求,將請求放入隊列,并立即向原始客戶端返回成功.第二個進(jìn)程從隊列中獲取請求,進(jìn)一步處理請求并將其放入另一個隊列.第三個進(jìn)程從第二個隊列中獲取請求并將其發(fā)送到原始服務(wù)器.

                  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 的新手,我知道它是事件驅(qū)動的,我還聽說最好不要將 Twisted 與線程或多處理混合使用.所以我不知道這種方式是否合適或者僅使用Twisted是否有更優(yōu)雅的方式?

                  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 有自己的事件驅(qū)動運(yùn)行子進(jìn)程的方式(在我的謙虛但正確的觀點中)比 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,你需要開發(fā)你自己的基于隊列的方法,以某種方式從子進(jìn)程獲取輸出到Twisted mainloop,因為正常的callFromThread 線程可能使用的 API 在另一個進(jìn)程中不起作用.根據(jù)你如何稱呼它,它要么嘗試腌制反應(yīng)器,要么只是在子進(jìn)程中使用不同的非工作反應(yīng)器;無論哪種方式,它都會永遠(yuǎn)失去你的電話.

                  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.

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

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

                          • 主站蜘蛛池模板: 中文天堂在线一区 | 黄色国产 | 中文字幕欧美日韩一区 | 久久伊人一区二区 | 91久久北条麻妃一区二区三区 | 免费在线观看成人av | 草久久| 一级做a爰片性色毛片16 | 国产偷自视频区视频 | 久久久久久高潮国产精品视 | 久久久久久亚洲精品 | 久久亚洲国产精品 | 久久综合一区二区 | 国产a一区二区 | 国产欧美精品一区二区三区 | 嫩草视频免费 | 91精品免费 | 美女久久 | 天天天操操操 | 蜜桃av一区二区三区 | 亚洲中午字幕 | 在线国产一区 | 精品毛片 | 国产一区 | 欧美精品1区2区3区 免费黄篇 | 欧美日本一区二区 | 91在线视频免费观看 | 天堂网中文字幕在线观看 | 亚洲网址在线观看 | 成人影音 | 国产精品一区二区三区在线 | 亚洲国产精品一区二区久久 | 日本免费视频在线观看 | 免费午夜视频 | 91久久精品国产91久久性色tv | 国产精品一区二区免费 | 中文字幕日韩av | 欧美成人激情 | 一区二区三区欧美 | av毛片在线 | 久久综合久久综合久久 |