久久久久久久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>
                        • 主站蜘蛛池模板: 日韩欧美理论片 | 一级黄色日本片 | 精品国产伦一区二区三区观看说明 | 99久久精品免费看国产四区 | 中文一区 | 色综合久久天天综合网 | 91久久| 91免费看片神器 | 日韩欧美在线视频观看 | 亚洲字幕在线观看 | 国产在线视频在线观看 | 久久精品日产第一区二区三区 | 精品国产不卡一区二区三区 | 日韩免费视频 | 久草综合在线 | av在线成人 | 九九综合| 精品一二三 | 精品影院 | 亚洲免费精品 | 国产乱人伦精品一区二区 | 高清人人天天夜夜曰狠狠狠狠 | 亚洲精品观看 | 欧美激情一区二区三区 | 精精国产xxxx视频在线 | 午夜精品一区二区三区三上悠亚 | 91精品一区 | 久久人人网 | 最新中文字幕在线 | 国产精品精品久久久 | 免费毛片在线 | 国产在线a视频 | 色资源在线 | www亚洲精品 | 精品国产一区二区国模嫣然 | 国产精品一区二区视频 | 一级片子 | 国产一级精品毛片 | 久久久性| 国产一区二区久久 | 黄a在线观看 |