improving performance of writing into a pipe

mikprog at gmail.com mikprog at gmail.com
Wed Feb 20 12:54:06 EST 2013


On Tuesday, February 19, 2013 5:47:16 PM UTC, Michael Torrie wrote:
> On 02/19/2013 02:24 AM, mikprog at gmail.com wrote:
> 
> > Or rather: what would you try to catch in this particular case?
> 
> 
> As Peter said, nothing for now.  But you seem very resistant to telling
> 
> us what exception was raised.


Michael believe me: 
I am not resistant or try to hide anything!
As written before, I don't know what exception to search for, so I wrote the (wrong) code:
except:
  print "error"
Let's why I don't have a clue about it.
But someone already explained me that I should not do this. 


 
> 
> Though looking at your code more closely I can see that likely the error
> 
> is related to the fact that /tmp/mypipe is not an executable program.

Yes it is and has rwx permissions.
Unfortunately I don't have access to the code in the pipe.



> > popen (which is deprecated and replaced by the subprocess module) is for
> 
> running programs and communicating with them over pipes created by the
> 
> popen function.  So your code is not likely to ever work as it is
> 
> presently given.
> 
> 
> 
> Here's the bash equivalent of your code:
> 
> 
> 
> $ mkfifo /tmp/path
> 
> $ cat </tmp/path &
> 
> $ echo hello, world | /tmp/path
> 
> 
> 
> Bash will say, "bash: /tmp/path: Permission denied"
> 
> 
> 
> The correct bash line is:
> 
> $ echo hello, world > /tmp/path
> 
> 
> 
> popen() (and subprocess) is the equivalent of the first bash command.
> 
> open() is the equivalent of the second line.
> 

> Do you understand the difference?


I think I do now, thanks.
mik



More information about the Python-list mailing list