Out of memory in Executor.map

Tags:

https://github.com/python/cpython/issues/74028

Executor.map 은 iterator에 있는 모든 입력을 submit 한 뒤에야 결과를 yield 합니다. 따라서 입력이 매우 크거나 무한의 데이터라면 out of memory 로 인해 죽게됩니다. 실제 에러는 이보다는 좀더 알기 어렵게 나오지만 메모리 사용량을 모니터링해보면 결국 메모리 탓인건 알 수 있습니다.

Executor.map을 쓰겠다면 데이터를 잘라서 메모리에 맞게 주거나 아니면 producer consumer 형태로 큐에 데이터를 넣고 빼는 원시적인(?) 코딩을 해야겠네요.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *