multiprocessing returns “too many open files” but using `with…as` fixes it. Why?
You’re creating new processes inside a loop, and then forgetting to close them once you’re done with them. As a result, there comes a point where you have too many open processes. This is a bad idea. You could fix this by using a context manager which automatically calls pool.terminate, or manually call pool.terminate yourself. … Read more