NumPy and memmap: [Errno 24] Too many open files

前端 未结 1 2046
离开以前
离开以前 2021-02-10 10:14

I am working with large matrixes, so I am using NumPy\'s memmap. However, I am getting an error as apparently the file descriptors used by memmap are not being closed.



        
1条回答
  •  暖寄归人
    2021-02-10 10:40

    Since the memmap does not take the open file descriptor, but the file name, I suppose you leak the temp_fd file descriptor. Does os.close(temp_fd) help?


    Great that it works.

    Since you can pass numpy.memmap a file-like object, you could create one from the file descriptor you already have, temp_fd.

    fobj = os.fdopen(temp_fd, "w+")
    numpy.memmap(fobj, ...
    

    0 讨论(0)
提交回复
热议问题