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

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

    1. <small id='9ciPH'></small><noframes id='9ciPH'>

      Python 多處理庫錯誤(AttributeError:__exit__)

      Python Multiprocessing Lib Error (AttributeError: __exit__)(Python 多處理庫錯誤(AttributeError:__exit__))
      • <small id='LeaZ5'></small><noframes id='LeaZ5'>

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

                  <tbody id='LeaZ5'></tbody>

              • <i id='LeaZ5'><tr id='LeaZ5'><dt id='LeaZ5'><q id='LeaZ5'><span id='LeaZ5'><b id='LeaZ5'><form id='LeaZ5'><ins id='LeaZ5'></ins><ul id='LeaZ5'></ul><sub id='LeaZ5'></sub></form><legend id='LeaZ5'></legend><bdo id='LeaZ5'><pre id='LeaZ5'><center id='LeaZ5'></center></pre></bdo></b><th id='LeaZ5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='LeaZ5'><tfoot id='LeaZ5'></tfoot><dl id='LeaZ5'><fieldset id='LeaZ5'></fieldset></dl></div>
              • 本文介紹了Python 多處理庫錯誤(AttributeError:__exit__)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                使用 pool.map(funct, iterable) 時出現此錯誤:

                Am getting this error when using the pool.map(funct, iterable):

                AttributeError: __exit__
                

                沒有解釋,只是堆棧跟蹤到模塊內的 pool.py 文件.

                No Explanation, only stack trace to the pool.py file within the module.

                這樣使用:

                with Pool(processes=2) as pool:
                   pool.map(myFunction, mylist)
                   pool.map(myfunction2, mylist2)
                

                我懷疑picklability可能存在問題(python需要pickle,或將列表數據轉換為字節流)但我不確定這是真的還是如何調試.

                I suspect there could be a problem with the picklability (python needs to pickle, or transform list data into byte stream) yet I'm not sure if this is true or if it is how to debug.

                產生此錯誤的新代碼格式:

                new format of code that produces this error :

                def governingFunct(list):
                    #some tasks
                    def myFunction():
                         # function contents
                    with closing(Pool(processes=2)) as pool:
                         pool.map(myFunction, sublist)
                         pool.map(myFunction2, sublist2)
                

                產生錯誤:

                PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed
                

                推薦答案

                在 Python 2.x 和 3.0、3.1 和 3.2 中,multiprocessing.Pool() 對象不是上下文管理器.您不能在 with 語句中使用它們.只有在 Python 3.3 及更高版本中,您才能使用它們.來自 Python 3 multiprocessing.Pool() 文檔:

                In Python 2.x and 3.0, 3.1 and 3.2, multiprocessing.Pool() objects are not context managers. You cannot use them in a with statement. Only in Python 3.3 and up can you use them as such. From the Python 3 multiprocessing.Pool() documentation:

                3.3 版中的新功能:池對象現在支持上下文管理協議 - 請參閱上下文管理器類型.__enter__() 返回池對象,__exit__() 調用 terminate().

                New in version 3.3: Pool objects now support the context management protocol – see Context Manager Types. __enter__() returns the pool object, and __exit__() calls terminate().

                對于早期的 Python 版本,您可以使用 contextlib.closing(),但考慮到這將調用 pool.close(),而不是 pool.terminate().在這種情況下手動終止:

                For earlier Python versions, you could use contextlib.closing(), but take into account this'll call pool.close(), not pool.terminate(). Terminate manually in that case:

                from contextlib import closing
                
                with closing(Pool(processes=2)) as pool:
                    pool.map(myFunction, mylist)
                    pool.map(myfunction2, mylist2)
                    pool.terminate()
                

                或創建自己的 terminating() 上下文管理器:

                or create your own terminating() context manager:

                from contextlib import contextmanager
                
                @contextmanager
                def terminating(thing):
                    try:
                        yield thing
                    finally:
                        thing.terminate()
                
                with terminating(Pool(processes=2)) as pool:
                    pool.map(myFunction, mylist)
                    pool.map(myfunction2, mylist2)
                

                這篇關于Python 多處理庫錯誤(AttributeError:__exit__)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='Eggor'></small><noframes id='Eggor'>

                  <i id='Eggor'><tr id='Eggor'><dt id='Eggor'><q id='Eggor'><span id='Eggor'><b id='Eggor'><form id='Eggor'><ins id='Eggor'></ins><ul id='Eggor'></ul><sub id='Eggor'></sub></form><legend id='Eggor'></legend><bdo id='Eggor'><pre id='Eggor'><center id='Eggor'></center></pre></bdo></b><th id='Eggor'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Eggor'><tfoot id='Eggor'></tfoot><dl id='Eggor'><fieldset id='Eggor'></fieldset></dl></div>
                  <legend id='Eggor'><style id='Eggor'><dir id='Eggor'><q id='Eggor'></q></dir></style></legend>
                      <tbody id='Eggor'></tbody>
                  1. <tfoot id='Eggor'></tfoot>
                          <bdo id='Eggor'></bdo><ul id='Eggor'></ul>
                        • 主站蜘蛛池模板: 精产国产伦理一二三区 | 懂色tv| 欧美三级电影在线播放 | 日韩二区 | 风间由美一区二区三区在线观看 | 中文字幕视频在线看5 | 午夜a v电影| av免费入口 | 中国免费黄色片 | 成人h视频 | 国产亚洲精品综合一区 | 成人h视频 | 亚洲伦理自拍 | 久久久久无码国产精品一区 | 亚洲黄色成人网 | 91免费电影 | 91在线视频一区 | 午夜小视频在线播放 | 久久久成人一区二区免费影院 | 自拍偷拍第一页 | 国产日韩欧美 | 人人干97 | 91看片免费 | 久久33 | 色视频网站免费 | 欧美一区二区三区免费电影 | 视频一区二区在线观看 | 91综合网 | 欧美精品tv | 成年人免费网站 | 久久精品小视频 | 成人午夜激情 | 天天天天操 | 午夜国产一级片 | 国产精品久久二区 | 成人免费观看视频 | 男人天堂国产 | 日韩精品一区二区三区高清免费 | 亚洲欧洲精品在线 | 欧美激情精品久久久久久 | 亚洲欧美在线视频 |