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

    1. <small id='szoFN'></small><noframes id='szoFN'>

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

        如何對“AttributeError: __exit__"進行故障排除在

        How to troubleshoot an quot;AttributeError: __exit__quot; in multiproccesing in Python?(如何對“AttributeError: __exit__進行故障排除在 Python 中進行多處理?)
        • <legend id='9UNN4'><style id='9UNN4'><dir id='9UNN4'><q id='9UNN4'></q></dir></style></legend>

            <bdo id='9UNN4'></bdo><ul id='9UNN4'></ul>

                • <small id='9UNN4'></small><noframes id='9UNN4'>

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

                  本文介紹了如何對“AttributeError: __exit__"進行故障排除在 Python 中進行多處理?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我嘗試重寫一些 csv 讀取代碼,以便能夠在 Python 3.2.2 的多個內核上運行它.我嘗試使用多處理的 Pool 對象,該對象是我從工作示例中改編而來的(并且已經為我的項目的另一部分工作).我遇到了一條難以解讀和排除故障的錯誤消息.

                  I tried to rewrite some csv-reading code to be able to run it on multiple cores in Python 3.2.2. I tried to use the Pool object of multiprocessing, which I adapted from working examples (and already worked for me for another part of my project). I ran into an error message I found hard to decipher and troubleshoot.

                  錯誤:

                  Traceback (most recent call last):
                    File "parser5_nodots_parallel.py", line 256, in <module>
                      MG,ppl = csv2graph(r)
                    File "parser5_nodots_parallel.py", line 245, in csv2graph
                      node_chunks)
                    File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/multiprocessing/pool.py", line 251, in map
                      return self.map_async(func, iterable, chunksize).get()
                    File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/multiprocessing/pool.py", line 552, in get
                      raise self._value
                  AttributeError: __exit__
                  

                  相關代碼:

                  import csv
                  import time
                  import datetime
                  import re
                  from operator import itemgetter
                  from multiprocessing import Pool
                  import itertools
                  
                  def chunks(l,n):
                      """Divide a list of nodes `l` in `n` chunks"""
                      l_c = iter(l)
                      while 1:
                          x = tuple(itertools.islice(l_c,n))
                          if not x:
                              return
                          yield x
                  
                  def csv2nodes(r):
                      strptime = time.strptime
                      mktime = time.mktime
                      l = []
                      ppl = set()
                      pattern = re.compile(r"""[A-Za-z0-9"/]+?(?=[,
                  ])""")
                      for row in r:
                          with pattern.findall(row) as f:
                              cell = int(f[3])
                              id = int(f[2])
                              st = mktime(strptime(f[0],'%d/%m/%Y'))
                              ed = mktime(strptime(f[1],'%d/%m/%Y'))
                          # collect list
                          l.append([(id,cell,{1:st,2: ed})])
                          # collect separate sets
                          ppl.add(id)
                      return (l,ppl)
                  
                  def csv2graph(source):
                      MG=nx.MultiGraph()
                      # Remember that I use integers for edge attributes, to save space! Dic above.
                      # start: 1
                      # end: 2
                      p = Pool()
                      node_divisor = len(p._pool)
                      node_chunks = list(chunks(source,int(len(source)/int(node_divisor))))
                      num_chunks = len(node_chunks)
                      pedgelists = p.map(csv2nodes,
                                         node_chunks)
                      ll = []
                      ppl = set()
                      for l in pedgelists:
                          ll.append(l[0])
                          ppl.update(l[1])
                      MG.add_edges_from(ll)
                      return (MG,ppl)
                  
                  with open('/Users/laszlosandor/Dropbox/peers_prisons/python/codetenus_test.txt','r') as source:
                      r = source.readlines()
                      MG,ppl = csv2graph(r)
                  

                  解決此問題的好方法是什么?

                  What's a good way to troubleshoot this?

                  推薦答案

                  問題出在這一行:

                  with pattern.findall(row) as f:
                  

                  您正在使用 with 語句.它需要一個帶有 __enter____exit__ 方法的對象.但是pattern.findall返回一個listwith試圖存儲__exit__方法,但是找不到它,并引發錯誤.只需使用

                  You are using the with statement. It requires an object with __enter__ and __exit__ methods. But pattern.findall returns a list, with tries to store the __exit__ method, but it can't find it, and raises an error. Just use

                  f = pattern.findall(row)
                  

                  改為.

                  這篇關于如何對“AttributeError: __exit__"進行故障排除在 Python 中進行多處理?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)

                  1. <tfoot id='zi5E6'></tfoot>

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

                        1. <legend id='zi5E6'><style id='zi5E6'><dir id='zi5E6'><q id='zi5E6'></q></dir></style></legend>
                            <bdo id='zi5E6'></bdo><ul id='zi5E6'></ul>

                              <tbody id='zi5E6'></tbody>
                            <i id='zi5E6'><tr id='zi5E6'><dt id='zi5E6'><q id='zi5E6'><span id='zi5E6'><b id='zi5E6'><form id='zi5E6'><ins id='zi5E6'></ins><ul id='zi5E6'></ul><sub id='zi5E6'></sub></form><legend id='zi5E6'></legend><bdo id='zi5E6'><pre id='zi5E6'><center id='zi5E6'></center></pre></bdo></b><th id='zi5E6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='zi5E6'><tfoot id='zi5E6'></tfoot><dl id='zi5E6'><fieldset id='zi5E6'></fieldset></dl></div>
                            主站蜘蛛池模板: 日韩免费视频 | 国精品一区二区 | 国产99久久精品一区二区300 | 日韩在线播放av | 午夜在线视频 | 自拍视频一区二区三区 | 亚洲视频网 | 草草影院ccyy | 黄网免费 | 国产91网站在线观看 | 精品九九久久 | 国产一区二区视频免费在线观看 | 国产精品久久久久久久久久 | 一级做a爰片性色毛片16 | 欧美视频二区 | 免费精品在线视频 | 你懂的国产| 中文字幕在线观看 | 国产精品视频网址 | 97视频在线免费 | 欧美日韩手机在线观看 | 国产91一区二区三区 | 久久国产精品一区二区 | va在线| 中日av | 国产欧美精品一区二区色综合朱莉 | 91麻豆精品国产91久久久久久久久 | 中文字幕精品视频 | www.99热.com| 日本精品久久 | 麻豆91精品91久久久 | 久久婷婷色 | jizz18国产| 九九一级片| 亚洲电影在线播放 | 日韩精品视频在线播放 | 中文精品一区二区 | 男女午夜激情视频 | 91视频在线看 | 国产精品无码永久免费888 | 欧美日韩精品 |