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

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

        <legend id='kahgy'><style id='kahgy'><dir id='kahgy'><q id='kahgy'></q></dir></style></legend>
        <tfoot id='kahgy'></tfoot>

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

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

      1. 星圖與tqdm結合?

        Starmap combined with tqdm?(星圖與tqdm結合?)
        <i id='DBYLW'><tr id='DBYLW'><dt id='DBYLW'><q id='DBYLW'><span id='DBYLW'><b id='DBYLW'><form id='DBYLW'><ins id='DBYLW'></ins><ul id='DBYLW'></ul><sub id='DBYLW'></sub></form><legend id='DBYLW'></legend><bdo id='DBYLW'><pre id='DBYLW'><center id='DBYLW'></center></pre></bdo></b><th id='DBYLW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='DBYLW'><tfoot id='DBYLW'></tfoot><dl id='DBYLW'><fieldset id='DBYLW'></fieldset></dl></div>

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

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

              <tfoot id='DBYLW'></tfoot>
                • <bdo id='DBYLW'></bdo><ul id='DBYLW'></ul>
                    <tbody id='DBYLW'></tbody>
                • 本文介紹了星圖與tqdm結合?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我在做一些并行處理,如下:

                  I am doing some parallel processing, as follows:

                  with mp.Pool(8) as tmpPool:
                          results = tmpPool.starmap(my_function, inputs)
                  

                  輸入如下所示:[(1,0.2312),(5,0.52) ...]即,int 和 float 的元組.

                  where inputs look like: [(1,0.2312),(5,0.52) ...] i.e., tuples of an int and a float.

                  代碼運行良好,但我似乎無法將其包裹在加載欄 (tqdm) 周圍,例如可以使用 imap 方法完成,如下所示:

                  The code runs nicely, yet I cannot seem to wrap it around a loading bar (tqdm), such as can be done with e.g., imap method as follows:

                  tqdm.tqdm(mp.imap(some_function,some_inputs))
                  

                  星圖也可以這樣做嗎?

                  謝謝!

                  推薦答案

                  starmap() 是不行的,但是通過添加 Pool.istarmap() 的補丁是可以的>.它基于 imap() 的代碼.您所要做的就是創建 istarmap.py-文件并導入模塊以應用補丁,然后再進行常規的多處理導入.

                  It's not possible with starmap(), but it's possible with a patch adding Pool.istarmap(). It's based on the code for imap(). All you have to do, is create the istarmap.py-file and import the module to apply the patch before you make your regular multiprocessing-imports.

                  Python <3.8

                  # istarmap.py for Python <3.8
                  import multiprocessing.pool as mpp
                  
                  
                  def istarmap(self, func, iterable, chunksize=1):
                      """starmap-version of imap
                      """
                      if self._state != mpp.RUN:
                          raise ValueError("Pool not running")
                  
                      if chunksize < 1:
                          raise ValueError(
                              "Chunksize must be 1+, not {0:n}".format(
                                  chunksize))
                  
                      task_batches = mpp.Pool._get_tasks(func, iterable, chunksize)
                      result = mpp.IMapIterator(self._cache)
                      self._taskqueue.put(
                          (
                              self._guarded_task_generation(result._job,
                                                            mpp.starmapstar,
                                                            task_batches),
                              result._set_length
                          ))
                      return (item for chunk in result for item in chunk)
                  
                  
                  mpp.Pool.istarmap = istarmap
                  

                  Python 3.8+

                  # istarmap.py for Python 3.8+
                  import multiprocessing.pool as mpp
                  
                  
                  def istarmap(self, func, iterable, chunksize=1):
                      """starmap-version of imap
                      """
                      self._check_running()
                      if chunksize < 1:
                          raise ValueError(
                              "Chunksize must be 1+, not {0:n}".format(
                                  chunksize))
                  
                      task_batches = mpp.Pool._get_tasks(func, iterable, chunksize)
                      result = mpp.IMapIterator(self)
                      self._taskqueue.put(
                          (
                              self._guarded_task_generation(result._job,
                                                            mpp.starmapstar,
                                                            task_batches),
                              result._set_length
                          ))
                      return (item for chunk in result for item in chunk)
                  
                  
                  mpp.Pool.istarmap = istarmap
                  

                  然后在你的腳本中:

                  import istarmap  # import to apply patch
                  from multiprocessing import Pool
                  import tqdm    
                  
                  
                  def foo(a, b):
                      for _ in range(int(50e6)):
                          pass
                      return a, b    
                  
                  
                  if __name__ == '__main__':
                  
                      with Pool(4) as pool:
                          iterable = [(i, 'x') for i in range(10)]
                          for _ in tqdm.tqdm(pool.istarmap(foo, iterable),
                                             total=len(iterable)):
                              pass
                  

                  這篇關于星圖與tqdm結合?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='6H4uL'></tfoot>
                  1. <i id='6H4uL'><tr id='6H4uL'><dt id='6H4uL'><q id='6H4uL'><span id='6H4uL'><b id='6H4uL'><form id='6H4uL'><ins id='6H4uL'></ins><ul id='6H4uL'></ul><sub id='6H4uL'></sub></form><legend id='6H4uL'></legend><bdo id='6H4uL'><pre id='6H4uL'><center id='6H4uL'></center></pre></bdo></b><th id='6H4uL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='6H4uL'><tfoot id='6H4uL'></tfoot><dl id='6H4uL'><fieldset id='6H4uL'></fieldset></dl></div>

                  2. <legend id='6H4uL'><style id='6H4uL'><dir id='6H4uL'><q id='6H4uL'></q></dir></style></legend>

                    • <bdo id='6H4uL'></bdo><ul id='6H4uL'></ul>

                        <tbody id='6H4uL'></tbody>

                          <small id='6H4uL'></small><noframes id='6H4uL'>

                          1. 主站蜘蛛池模板: 久久精品手机视频 | 午夜伦4480yy私人影院 | 久久久久www | 亚洲综合区| 国产精品久久久久久久久久妞妞 | av网站免费在线观看 | 亚洲国产精品久久久久婷婷老年 | 久久国产精品一区二区三区 | 亚州精品成人 | 亚洲一区久久 | 国产999精品久久久 日本视频一区二区三区 | 蜜桃精品噜噜噜成人av | 国产在线拍偷自揄拍视频 | 国产一区二区三区四区三区四 | 久久久精品一区二区 | 久久久久久久久久久久久91 | 欧美精品在线一区 | 国产精品视频在线观看 | 色橹橹欧美在线观看视频高清 | 欧美精品在线播放 | 午夜极品 | 97av在线 | 国产99久久精品一区二区永久免费 | 国产精品电影网 | 亚洲精品久久 | 国产成人免费视频 | 亚洲成人在线免费 | 亚洲欧美激情国产综合久久久 | 香蕉久久久 | 精品一区二区三区不卡 | 精品一区二区久久久久久久网精 | 日本亚洲一区 | 91高清在线观看 | 99久久精品国产一区二区三区 | 日韩在线免费视频 | 成人免费一区二区三区视频网站 | 中文字幕一区二区三区精彩视频 | 成人欧美一区二区三区在线播放 | 欧美一区二 | 亚洲精品视频在线观看视频 | 一区二区日韩 |