How to troubleshoot an “AttributeError: __exit__” in multiproccesing in Python?

后端 未结 4 675
执笔经年
执笔经年 2020-12-13 22:41

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 adap

4条回答
  •  执念已碎
    2020-12-13 23:38

    It is not the asker's problem in this instance but the first troubleshooting step for a generic "AttributeError: __exit__" should be making sure the brackets are there, e.g.

    with SomeContextManager() as foo:
        #works because a new object is referenced...
    

    not

    with SomeContextManager as foo:
        #AttributeError because the class is referenced
    

    Catches me out from time to time and I end up here -__-

提交回复
热议问题