Given mmap's constructor declaration:
class mmap.mmap(fileno, length[, flags[, prot[, access[, offset]]]])
How do I specify both access & offset?
The documentation states:
access may be specified in lieu of flags and prot as an optional keyword parameter. It is an error to specify both flags, prot and access. See the description of access above for information on how to use this parameter.
So I've tried to do things like
mmap.mmap(file_no, length, offset, access=mmap.ACCESS_COPY)
mmap.mmap(file_no, length, access=mmap.ACCESS_COPY, offset=offset)
m = mmap.mmap(f.fileno(), 4, access=mmap.ACCESS_COPY, offset=2)
Traceback (most recent call last):
File "", line 1, in mmap.error: [Errno 22] Invalid argument
mmap.mmap(file_no, length, mmap.ACCESS_COPY, offset)
But I can't get it to work. Why is this confusing me so much?
This error is unrelated to access. As documented, the offset just must be a multiple of mmap.PAGESIZE
or mmap.ALLOCATIONGRANULARITY
.
try with:
m = mmap.mmap(f.fileno(), 4, access=mmap.ACCESS_COPY, offset=2 * mmap.ALLOCATIONGRANULARITY)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With