Python mmap return Invalid argument

43 Views Asked by At

I tried to use mmap in Python

import mmap
import sys
f = open(sys.argv[1])
off = int(sys.argv[2])
mm = mmap.mmap(f.fileno(),length=0,access=mmap.ACCESS_READ,offset=off )

When off =0 that works fine .

But when off equal to any number (100 for example) I got OSError: [ERROR 22] Invalid argument

1

There are 1 best solutions below

3
SIGHUP On BEST ANSWER

The offset must be a multiple of mmap.ALLOCATIONGRANULARITY but cannot be larger than the file size