[GRASS-dev] [GRASS-user] r.to.vect stats

Moritz Lennert mlennert at club.worldonline.be
Fri May 5 00:43:53 PDT 2017


Le Thu, 4 May 2017 23:07:38 -0400,
Vaclav Petras <wenzeslaus at gmail.com> a écrit :

> On Wed, May 3, 2017 at 5:34 AM, Moritz Lennert
> <mlennert at club.worldonline.be> wrote:
>  [...]  
>  [...]  
> >
> > Do you really need the in_process.communicate() ? Here's what I used
> > in a local script and it works, without communicate(). Then again,
> > I don't think the data flowing through this pipe ever exceeded
> > available  
> memory.
> >
> >         pin = gscript.pipe_command('v.db.select',
> >                                    map = firms_map,
> > ...
> >         total_turnover_map = 'turnover_%s' % nace2
> >         p = gscript.start_command('r.in.xyz',
> >                                   input_='-',
> >                                   stdin=pin.stdout,
> > ...
> >         if p.wait() is not 0:
> >             gscript.fatal("Error in r.in.xyz with nace %s" %
> > nace2)  
> 
> The Popen.wait() documentation [1] says: "Warning: This will deadlock
> when using stdout=PIPE and/or stderr=PIPE and the child process
> generates enough output to a pipe such that it blocks waiting for the
> OS pipe buffer to accept more data. Use communicate() to avoid that."

Doesn't the stdout/stderr=PIPE here refer to the process that you call
wait() on, i.e. p in my example ? And p does not use stdout=PIPE. But I
have to admit that I'm far outside comfortable waters in terms of my
level of understanding... ;-)

Markus is probably right: working with an intermediate file solves all
this and I don't think it would imply a serious speed decrease.

Moritz


More information about the grass-dev mailing list