discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] os.popen broken pipe error


From: Thomas Schmid
Subject: Re: [Discuss-gnuradio] os.popen broken pipe error
Date: Mon, 13 Apr 2009 08:30:36 -0700

python pipes are buffered. if your command produces a lot of output,
then the pipes can fill up, if you don't read from them. One solution
is to move to the subprocess module:

 http://docs.python.org/library/subprocess.html#module-subprocess

Cheers,

Thomas

On Sun, Apr 12, 2009 at 9:52 PM,  <address@hidden> wrote:
>> On Sun, Apr 12, 2009 at 08:42:59PM -0400, address@hidden wrote:
>>> Hi,
>>>
>>> I am trying to open one python script from another using the following
>>> code:
>>>
>>>
>>> command = 'python send.py -d %d -s %d -c %d -n %d -f trash_file.txt'
>>> %(dest_addr, sender_addr, cmd, seqno)
>>> os.popen(command)
>>>
>>> I get the broken pipe error for some reason. Can anyone please explain
>>> what is happening? Following are the file links if you want to reproduce
>>> the error:
>>
>> A "broken pipe" occurs when when you attempt to write on a pipe
>> without a reader (See man 7 pipe).
>>
>> You're not specifying the second argument to os.popen.
>> It defaults to 'r'.  Do you want 'w'?
>>
>> See the python library reference for more info.
>>
>>> http://www.eden.rutgers.edu/~aanchan/input.txt
>>> http://www.eden.rutgers.edu/~aanchan/send.py
>>> http://www.eden.rutgers.edu/~aanchan/transceiver.py
>>> http://www.eden.rutgers.edu/~aanchan/trash_file.txt
>>>
>>> I am calling send.py from transceiver.py. The txt files are used as
>>> inputs.
>>>
>>> thanks and regards,
>>>
>>> -Sumit
>>>
>>
>> Eric
>>
>
> I was surprised actually when I got the above mentioned bug because I had
> have always been giving only one argument, when I wanted the "command" to
> be executed on the shell. Anyway, the problem was actually solved when I
> stored the output of the above "command" in a text file (rx_ack_log.txt)
> as follows:
>
> command = 'python send.py -d %d -s %d -c %d -n %d -f trash_file.txt >>
> rx_ack_log.txt' %(dest_addr, sender_addr, cmd, seqno)
> os.popen(command)
>
> thanks for the help!
> regards,
> -Sumit
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>



-- 
"Don't complain; Just work harder" - Randy Pausch

Thomas Schmid, Ph.D. Candidate
Networked & Embedded Systems Laboratory (NESL)
University of California, Los Angeles (UCLA)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]