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

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

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

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

        回調函數在多處理 map_async 中如何工作?

        How does the callback function work in multiprocessing map_async?(回調函數在多處理 map_async 中如何工作?)

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

              <tbody id='vGEPV'></tbody>
            • <bdo id='vGEPV'></bdo><ul id='vGEPV'></ul>
                • <legend id='vGEPV'><style id='vGEPV'><dir id='vGEPV'><q id='vGEPV'></q></dir></style></legend>
                • <tfoot id='vGEPV'></tfoot>
                  <i id='vGEPV'><tr id='vGEPV'><dt id='vGEPV'><q id='vGEPV'><span id='vGEPV'><b id='vGEPV'><form id='vGEPV'><ins id='vGEPV'></ins><ul id='vGEPV'></ul><sub id='vGEPV'></sub></form><legend id='vGEPV'></legend><bdo id='vGEPV'><pre id='vGEPV'><center id='vGEPV'></center></pre></bdo></b><th id='vGEPV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='vGEPV'><tfoot id='vGEPV'></tfoot><dl id='vGEPV'><fieldset id='vGEPV'></fieldset></dl></div>
                  本文介紹了回調函數在多處理 map_async 中如何工作?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  調試代碼花了我一晚上的時間,終于發現了這個棘手的問題.請看下面的代碼.

                  It cost me a whole night to debug my code, and I finally found this tricky problem. Please take a look at the code below.

                  from multiprocessing import Pool
                  
                  def myfunc(x):
                      return [i for i in range(x)]
                  
                  pool=Pool()
                  
                  A=[]
                  r = pool.map_async(myfunc, (1,2), callback=A.extend)
                  r.wait()
                  

                  我以為我會得到 A=[0,0,1],但輸出是 A=[[0],[0,1]].這對我來說沒有意義,因為如果我有 A=[]A.extend([0])A.extend([0,1]) 會給我A=[0,0,1].回調可能以不同的方式工作.所以我的問題是如何獲得 A=[0,0,1] 而不是 [[0],[0,1]]?

                  I thought I would get A=[0,0,1], but the output is A=[[0],[0,1]]. This does not make sense to me because if I have A=[], A.extend([0]) and A.extend([0,1]) will give me A=[0,0,1]. Probably the callback works in a different way. So my question is how to get A=[0,0,1] instead of [[0],[0,1]]?

                  推薦答案

                  如果使用 map_async,則調用一次回調并返回結果 ([[0], [0, 1]]).

                  Callback is called once with the result ([[0], [0, 1]]) if you use map_async.

                  >>> from multiprocessing import Pool
                  >>> def myfunc(x):
                  ...     return [i for i in range(x)]
                  ... 
                  >>> A = []
                  >>> def mycallback(x):
                  ...     print('mycallback is called with {}'.format(x))
                  ...     A.extend(x)
                  ... 
                  >>> pool=Pool()
                  >>> r = pool.map_async(myfunc, (1,2), callback=mycallback)
                  >>> r.wait()
                  mycallback is called with [[0], [0, 1]]
                  >>> print(A)
                  [[0], [0, 1]]
                  

                  使用 apply_async如果您希望每次都調用回調.

                  Use apply_async if you want callback to be called for each time.

                  pool=Pool()
                  results = []
                  for x in (1,2):
                      r = pool.apply_async(myfunc, (x,), callback=mycallback)
                      results.append(r)
                  for r in results:
                      r.wait()
                  

                  這篇關于回調函數在多處理 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屋-程序員
                  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)

                  <tfoot id='wGmrU'></tfoot>

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

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

                          <tbody id='wGmrU'></tbody>

                            <bdo id='wGmrU'></bdo><ul id='wGmrU'></ul>
                            主站蜘蛛池模板: 成人在线精品视频 | www久久爱| 国产精品美女久久久久aⅴ国产馆 | 国产一区二区欧美 | 免费天天干 | 天天狠狠| 色吊丝在线 | 成人av免费播放 | 色婷婷av久久久久久久 | 激情综合五月 | 91精品国产一区二区三区动漫 | 国产精品久久久久久吹潮 | av高清 | 免费在线毛片 | 狠狠av | 三级成人片 | 久久99精品久久久久久噜噜 | 夜夜爽99久久国产综合精品女不卡 | 亚洲天堂网站 | 一级毛片黄片 | 中文字幕av一区 | 国产精品免费一区二区三区四区 | 欧美日韩高清在线观看 | 欧美在线a | 亚洲风情在线观看 | 久久久久久久久久久高潮一区二区 | 五月天天色 | 欧美 日韩 中文 | 国产精品久久久久久久久久久久久久 | 国产精品一区免费 | 日本中出视频 | 免费看91 | 久久精品一区二区三区四区 | 欧美一区在线视频 | 中文成人在线 | 成人小视频在线观看 | 久久久999免费视频 999久久久久久久久6666 | 天天色天天色 | 日韩av免费在线电影 | 女同久久另类99精品国产 | 国产精品高潮呻吟久久av野狼 |