IOError: [Errno 4] Interrupted system call

Gabriel Genellina gagsl-py at yahoo.com.ar
Sat Feb 17 00:25:02 EST 2007


En Fri, 16 Feb 2007 18:07:40 -0300, <chadrik at gmail.com> escribió:

> i don't have any signal handlers in my code, but i have no idea what
> is going on in the internals of the pyQt framework that i'm using for
> the GUI.
>
> p = subprocess.Popen('mycommand', shell=True, stdin=subprocess.PIPE,
> stdout=subprocess.PIPE, close_fds=True)
> 		output = p.stdout.readlines()

There is a problem using a high-level approach like readlines(): *either*  
there is no exception, and you get all the output, *or* there is an  
exception and you get nothing. readlines() can't return a partial result  
*and* raise an exception at the same time. (Perhaps EINTR should be a  
special case, but currently it's converted into an IOError like all other  
error codes).

You could read one character at a time with read(1) (to minimize the risk  
of data loss), or simply use a temporary file: "mycomand >temporary" and  
then read its contents. This appears to be the safest way.

-- 
Gabriel Genellina




More information about the Python-list mailing list