[Top][All Lists]

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

Re: [Discuss-gnuradio] Python message passing block hangs (test file inc

From: Tom Rondeau
Subject: Re: [Discuss-gnuradio] Python message passing block hangs (test file included)
Date: Sun, 15 Mar 2015 16:09:41 -0400

On Thu, Mar 12, 2015 at 5:00 PM, Anderson, Douglas J. <address@hidden> wrote:
Hi all,

I'm struggling to understand an issue I'm having with a simple python block with a registered message port connected to the copy block.

The python block looks like this: it literally does nothing, it just happens to have a message port registered:

class signal_sink(gr.sync_block):
  def __init__(self):
    gr.sync_block.__init__(self, name="sink", in_sig=[np.float32], out_sig=None)
    self.signal = pmt.from_bool(False)
    self.port_name = pmt.intern("sig")

def work(self, input_items, output_items):
    return len(input_items[0])

Then I have a gr.unittest case that connects a vector_source, the copy block, and the above signal sink:

def test_copy(self):
    src_data = np.arange(1000)
    src = "">
    copy = blocks.copy(gr.sizeof_float)
    msg_debug = blocks.message_debug()
    sig_sink = signal_sink()
    self.tb.connect(src, copy, sig_sink)
    self.tb.msg_connect(sig_sink, "sig", copy, "en")

    # Run once (this run is successful)

    # Run again (this run hangs)

second time the flowgraph is "run", it hangs indefinitely. GDB shows sig_sink's thread state as
#0 pthread_cond_timedwait@@GLIBC_2.3.2 ()
at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:238

Commenting out the "self.tb.msg_connect" line stops the hang, as does connecting sig_sink's message port to a message_debug block (which is not in the flowgraph).

All this even though the sig_sink block doesn't send any signals over its message port.

Any hints would be very much appreciated, my debugging prowess has taken me as far as it's going to take me.

I've attached the complete test file that you can run with "python test.py"

Thanks in advance,

Hi Doug,

What version of GNU Radio are you running (gnuradio-config-info -v)? I just tested your test.py script locally and it worked fine. We've put in a patch for the shutdown system that I think it's related to your problem, but it has not been in a version release, yet. The patch is pretty simple:

commit 035b9d016dffefec890323bd0b24dbaf23aa9186
Author: Tom Rondeau <address@hidden>
Date:   Wed Feb 4 13:06:14 2015 +0000

    runtime: possible bug fix for limited-run flowgraphs with message-only blocks.

diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc
index 9173094..f26d6bb 100644
--- a/gnuradio-runtime/lib/block.cc
+++ b/gnuradio-runtime/lib/block.cc
@@ -750,7 +750,10 @@ namespace gr {
-    return d_finished;
+    if((detail()->ninputs() != 0) || (detail()->noutputs() != 0))
+      return false;
+    else
+      return d_finished;
If you want to give that a try, I'm interested to hear feedback on this problem and solution.


reply via email to

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