#2879: grass.script.array cannot read raster on Windows
-----------------------------+-------------------------
Reporter: annakrat | Owner: grass-dev@…
Type: defect | Status: new
Priority: critical | Milestone: 7.0.3
Component: Python | Version: svn-trunk
Keywords: wingrass, numpy | CPU: Unspecified
Platform: MSWindows 8 |
-----------------------------+-------------------------
When testing the example from documentation
[https://grass.osgeo.org/grass71/manuals/libpython/script.html here]
{{{
map2d_2.read("map2d_1")
}}}
doesn't work and fails because r.out.bin can't write into the temporary
file. This file is created when the array is initialized and it is open,
so on Windows no other process can write to it.
> This file is created when the array is initialized and it is open, so on
Windows no other process can write to it.
It's possible for multiple processes to write to the same file, but that
may require specifying additional flags (which neither the underlying
numpy.memmap constructor nor Python's mmap.mmap constructor appear to
support). OTOH, it's also possible that Windows doesn't allow writing to
files which are memory-mapped.
It isn't possible to avoid opening the file in the constructor, so the
only other option would be to optionally pass the mapname and null
parameters to the constructor and have the constructor call the read()
method before calling the parent constructor.
Replying to [comment:3 glynn]:
> > It isn't possible to avoid opening the file in the constructor, so the
only other option would be to optionally pass the mapname and null
parameters to the constructor and have the constructor call the read()
method before calling the parent constructor.
I implemented this in r67710 some time ago and tested on Linux and
Windows. I don't think we should backport it, since it changes the API. If
people agree, I would close this as solved.
> I implemented this in r67710 some time ago and tested on Linux and
Windows. I don't think we should backport it, since it changes the API. If
people agree, I would close this as solved.