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

The problem is in this line:

with pattern.findall(row) as f:

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

f = pattern.findall(row)

instead.

Leave a Comment