[GRASS-dev] [GRASS GIS] #2326: Command functions in grass.script.core miss a correct error reporting
GRASS GIS
trac at osgeo.org
Fri Jun 6 02:48:08 PDT 2014
#2326: Command functions in grass.script.core miss a correct error reporting
-------------------------+--------------------------------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
Type: enhancement | Status: new
Priority: normal | Milestone: 7.1.0
Component: Python | Version: svn-trunk
Keywords: script | Platform: All
Cpu: Unspecified |
-------------------------+--------------------------------------------------
Comment(by glynn):
Replying to [ticket:2326 wenzeslaus]:
I missed this issue in my previous reply:
>
{{{
proc.stdin.write(proj_in)
proc.stdin.close()
proc.stdin = None
proj_out, errors = proc.communicate()
}}}
You need to use
{{{
proj_out, errors = proc.communicate(proj_in)
}}}
If you try to .write() the data to stdin, and the child process prints
progress/error/etc messages as it processes the input, you'll get deadlock
if the amount of data written to either pipe exceeds the amount which will
fit in the pipe's buffer.
The .communicate() method uses either non-blocking I/O (Unix) or threads
(Windows) in order to consume output as it becomes available, rather than
waiting until all data has been written to stdin and hoping that the
pipe's buffer can contain everything written to stdout/stderr in the
meantime.
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2326#comment:4>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list