Simulate `bash` behaviour using Python and named pipes.

Luca Cerone luca.cerone at gmail.com
Mon Aug 5 10:11:52 EDT 2013


Hi MRAB, thanks for the reply!
> 
> Opening the pipe for reading will block until it's also opened for
> 
> writing, and vice versa.
> 

OK.

> 
> 
> In your bash code, 'ls' blocked until you ran 'cat', but because you
> 
> ran 'ls' in the background you didn't notice it!
> 
> 
Right.
> 
> In your Python code, the Python thread blocked on opening the pipe for
> 
> writing. It was waiting for another thread or process to open the pipe
> 
> for reading.

OK. What you have written makes sense to me. So how do I overcome the block?
As you said in bash I run the ls process in background. How do I do that in Python?

Thanks again for the help,
Luca



More information about the Python-list mailing list