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

<legend id='AcDmO'><style id='AcDmO'><dir id='AcDmO'><q id='AcDmO'></q></dir></style></legend>

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

    • <bdo id='AcDmO'></bdo><ul id='AcDmO'></ul>

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

        如何將隊列引用傳遞給 pool.map_async() 管理的函數

        How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊列引用傳遞給 pool.map_async() 管理的函數?)

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

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

              • <legend id='q1aGp'><style id='q1aGp'><dir id='q1aGp'><q id='q1aGp'></q></dir></style></legend>
                • <bdo id='q1aGp'></bdo><ul id='q1aGp'></ul>
                  <tfoot id='q1aGp'></tfoot>
                • 本文介紹了如何將隊列引用傳遞給 pool.map_async() 管理的函數?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我想要一個長時間運行的進程通過隊列(或類似的東西)返回它的進度,我將把它提供給進度條對話框.當過程完成時,我還需要結果.此處的測試示例失敗并出現 RuntimeError: Queue objects should only be shared between processes through inheritance.

                  I want a long-running process to return its progress over a Queue (or something similar) which I will feed to a progress bar dialog. I also need the result when the process is completed. A test example here fails with a RuntimeError: Queue objects should only be shared between processes through inheritance.

                  import multiprocessing, time
                  
                  def task(args):
                      count = args[0]
                      queue = args[1]
                      for i in xrange(count):
                          queue.put("%d mississippi" % i)
                      return "Done"
                  
                  def main():
                      q = multiprocessing.Queue()
                      pool = multiprocessing.Pool()
                      result = pool.map_async(task, [(x, q) for x in range(10)])
                      time.sleep(1)
                      while not q.empty():
                          print q.get()
                      print result.get()
                  
                  if __name__ == "__main__":
                      main()
                  

                  我已經能夠使用單獨的 Process 對象(我 am 允許傳遞 Queue 引用)使其工作,但是我沒有一個池來管理我的許多進程想啟動.有什么更好的模式建議嗎?

                  I've been able to get this to work using individual Process objects (where I am alowed to pass a Queue reference) but then I don't have a pool to manage the many processes I want to launch. Any advise on a better pattern for this?

                  推薦答案

                  以下代碼似乎可以工作:

                  The following code seems to work:

                  import multiprocessing, time
                  
                  def task(args):
                      count = args[0]
                      queue = args[1]
                      for i in xrange(count):
                          queue.put("%d mississippi" % i)
                      return "Done"
                  
                  
                  def main():
                      manager = multiprocessing.Manager()
                      q = manager.Queue()
                      pool = multiprocessing.Pool()
                      result = pool.map_async(task, [(x, q) for x in range(10)])
                      time.sleep(1)
                      while not q.empty():
                          print q.get()
                      print result.get()
                  
                  if __name__ == "__main__":
                      main()
                  

                  請注意,隊列來自 manager.Queue() 而不是 multiprocessing.Queue().感謝 Alex 為我指明了這個方向.

                  Note that the Queue is got from a manager.Queue() rather than multiprocessing.Queue(). Thanks Alex for pointing me in this direction.

                  這篇關于如何將隊列引用傳遞給 pool.map_async() 管理的函數?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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屋-程序員
                  yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯誤的另一個混淆,“模塊對象沒有屬性“f)
                  Multiprocessing : use tqdm to display a progress bar(多處理:使用 tqdm 顯示進度條)

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

                      <tbody id='yzbN2'></tbody>
                        <tfoot id='yzbN2'></tfoot>

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

                        <i id='yzbN2'><tr id='yzbN2'><dt id='yzbN2'><q id='yzbN2'><span id='yzbN2'><b id='yzbN2'><form id='yzbN2'><ins id='yzbN2'></ins><ul id='yzbN2'></ul><sub id='yzbN2'></sub></form><legend id='yzbN2'></legend><bdo id='yzbN2'><pre id='yzbN2'><center id='yzbN2'></center></pre></bdo></b><th id='yzbN2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yzbN2'><tfoot id='yzbN2'></tfoot><dl id='yzbN2'><fieldset id='yzbN2'></fieldset></dl></div>
                            主站蜘蛛池模板: 久久婷婷色| 免费av手机在线观看 | 国产98色在线 | 日韩 | 福利视频二区 | av毛片| 国产成人精品午夜视频免费 | 91精品国产色综合久久 | 91精品国产色综合久久不卡蜜臀 | 国产精品一区久久久 | 欧美二区在线 | 国产成人综合亚洲欧美94在线 | 麻豆久久久久久久久久 | 欧美日韩国产三级 | 午夜亚洲| 国产精品久久久久久久7777 | 亚洲天堂av网 | 国产a爽一区二区久久久 | 日韩电影在线一区 | 久久综合久 | 超碰成人免费 | 亚洲一区二区三区免费在线观看 | 亚洲精品欧美精品 | 精品免费看 | 伊人精品在线视频 | 国产精品视频在线播放 | 在线色网 | 欧美一区二区三区在线看 | 伊人久久在线观看 | 有码在线 | 日韩在线观看一区 | 国产精品99视频 | 亚洲国产成人在线观看 | 一区二区三区高清不卡 | 视频精品一区 | 久久久久久久久久久久一区二区 | 中文字幕亚洲视频 | 久久久久久久久久久久久9999 | 成人欧美一区二区三区黑人孕妇 | 91精品国产综合久久久动漫日韩 | 国产精品视频一区二区三 | 亚洲一区二区三区四区五区午夜 |