Python mmap 'Permission denied' on Linux

后端 未结 4 1087
梦毁少年i
梦毁少年i 2021-02-18 14:26

I have a really large file I\'m trying to open with mmap and its giving me permission denied. I\'ve tried different flags and modes to the os.open but its just not

4条回答
  •  礼貌的吻别
    2021-02-18 15:03

    I think its a flags issue, try opening as read only:

    mfd = os.open('BigFile', os.O_RDONLY)
    

    and mmap.mmap by default tries to map read/write, so just map read only:

    mfile = mmap.mmap(mfd, 0, prot=mmap.PROT_READ)
    

提交回复
热议问题