[GRASS-dev] python scripts and standard input
Massimo Di Stefano
massimodisasha at gmail.com
Fri May 14 18:16:38 EDT 2010
Il giorno 30/apr/2010, alle ore 02.39, Glynn Clements ha scritto:
> 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))
> 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.
thanks Glynn i adopted this way and it works (but i haven't tested on windows)
>> 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.
i'm tring to find a way to follow your suggestions.
if "function()" is the subprocess action that give me error on osx
maybe i can try something like :
> Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev