Freeze when writing to linux fifo pipe

Hi,
I am trying to write to a linux pipe/fifo, but sadly this seems to
freeze python. I am using Ubuntu 10.04 and gnuradio 3.2.2.dfsg-1ubuntu1.
Please try to execute the code and tell me why this makes the app pause.

#! /usr/bin/python

Import stuff

from gnuradio import gr, gru, eng_notation, optfir
from gnuradio.eng_option import eng_option
from gnuradio.wxgui import slider, powermate
from gnuradio.wxgui import stdgui2, fftsink2, form, scopesink2
import sys
import os

Main application

class main_app (stdgui2.std_top_block):
def init(self,frame,panel,vbox,argv):
stdgui2.std_top_block.init (self,frame,panel,vbox,argv)

print '!!!Cleanup'
os.spawnlp(os.P_WAIT, 'rm', 'rm','/tmp/gnutest1.raw')
os.spawnlp(os.P_WAIT, 'rm', 'rm','/tmp/gnutest2.raw')
print '!!!make a fifo'
os.spawnlp(os.P_WAIT, 'mkfifo', 'mkfifo','/tmp/gnutest1.raw')
print '!!!make file sink without the fifo'
outok = gr.file_sink(gr.sizeof_short,'/tmp/gnutest2.raw')
print '!!!make file sink with the fifo (FREEZING)'
outcrash = gr.file_sink(gr.sizeof_short, '/tmp/gnutest1.raw')
print '!!!everything went better than expected'

if name == ‘main’:
app = stdgui2.stdapp (main_app, “crashtest”)
app.MainLoop ()

GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

On 04/20/2010 08:57 AM, Joachim R. wrote:

from gnuradio.wxgui import stdgui2, fftsink2, form, scopesink2
os.spawnlp(os.P_WAIT, ‘rm’, ‘rm’,’/tmp/gnutest2.raw’)
app.MainLoop ()

An open(2) call on a FIFO (named pipe) will only complete when the other
side (the reader) has opened
the named-pipe for reading. So your app will freeze until there’s a
reader for the pipe.

You can open the FIFO non-blocking, but I don’t know how you do that in
the gr.file_sink call.


Marcus L.
Principal Investigator
Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org

On Tue, Apr 20, 2010 at 02:57:04PM +0200, Joachim R. wrote:

Hi,
I am trying to write to a linux pipe/fifo, but sadly this seems to freeze python. I am using Ubuntu 10.04 and gnuradio 3.2.2.dfsg-1ubuntu1.
Please try to execute the code and tell me why this makes the app pause.

$ man 3 mkfifo

Opening a fifo for reading blocks until there is a writer and vice
versa…

Eric

On Wed, Apr 21, 2010 at 11:30:32PM -0400, Marcus D. Leech wrote:

Eric

Actually, an open for read will always succeed, lest you create
unpleasant deadlock situations…

Hmmm. FWIW, from Linux: man 3 mkfifo

Opening a FIFO for reading normally blocks until some other process
opens the same FIFO for writing, and vice versa. See fifo(7) for
non-blocking handling of FIFO special files.

Eric

On 04/21/2010 11:26 PM, Eric B. wrote:

Eric

Actually, an open for read will always succeed, lest you create
unpleasant deadlock situations…


Marcus L.
Principal Investigator
Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs