[GRASS-dev] python scripts and standard input
Glynn Clements
glynn at gclements.plus.com
Thu Apr 29 20:39:24 EDT 2010
Massimo Di Stefano wrote:
> actually i'm using :
>
> out = subprocess.Popen(['m.proj', '-o'], stdout=subprocess.PIPE, stdin=subprocess.PIPE).communicate("%s %s" % (x,y))[0]
That will work on Unix, but Windows will complain due to the lack of
the .exe suffix. You can use grass.Popen() to get around that.
> This topic, maybe is good to discuss a problem i'm having about subprocess,
> please apologize me if it is OT, tell me to open a new thread.
>
> The error i'm having is strictly connected with subprocess and how grass handle it.
> The weird is that the error i'm having comes up only on OSX while on linux all works fine.
>
> this the error log :
> File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 663, in communicate
> stdout = self.stdout.read()
> IOError: [Errno 4] Interrupted system call
This appears to be a bug either in Python's read() method for pipes or
in Python's subprocess module. The underlying read() is failing with
EINTR, which can happen if a signal is received during a blocking
system call.
Normally, you would configure the signal handler to resume any system
calls (unless you specifically want it to interrupt blocking calls,
e.g. implementing a timeout by setting a timer and having SIGALRM
interrupt the system call).
In this case, I would expect the code to just try again, rather than
raising an exception. EINTR and EAGAIN are "transient" errors, in that
a subsequent attempt will typically succeed.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list