# Message queues - Inconsistent data problem

**URL:** <https://www.ruby-forum.com/t/message-queues-inconsistent-data-problem/230681>\
**Category:** GNU Radio\
**Created:** [June 29, 2014, 4:09pm UTC](https://www.ruby-forum.com/t/message-queues-inconsistent-data-problem/230681 "2014-06-29T16:09:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@jason\_sam](https://www.ruby-forum.com/u/jason_sam)\
**Post date:** [June 29, 2014, 4:09pm UTC](https://www.ruby-forum.com/t/message-queues-inconsistent-data-problem/230681/1 "2014-06-29T16:09:04Z")

</div>

Hello,

I’m using Gnuradio version: v3.7.2.1-62 and am facing a strange issue  
with message queuing.

I wrote a testing “hier” block which holds 2 message blocks (source +  
sink).

* * *

#create blocks  
msgq\_in = gr.msg\_queue(2)  
msgq\_out = gr.msg\_queue(2)  
msg\_sink = blocks.message\_sink(gr.sizeof\_char, msgq\_in, False)  
msg\_source = blocks.message\_source(gr.sizeof\_char, msgq\_out)

## #connect self.connect(self, msg\_sink) self.connect(msg\_source, self)

The hier block run a thread which read messages from the message\_sink  
and send them to message\_source. Nothing more.  
The final flow graph is “File source” → “Hier block” → “File Sink”

The full python code is here:

> **[\#!/usr/bin/env pythonfrom gnuradio import grfrom gnuradio import blocksi -...](https://pastebin.com/AfFhEGQ6)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

The problem:

/tmp/source contains “abcdefghijklmnopqrstuvwxz0123456789” + new line:

$ hexdump -C /tmp/source  
00000000 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70  
|abcdefghijklmnop|  
00000010 71 72 73 74 75 76 77 78 7a 30 31 32 33 34 35 36  
|qrstuvwxz0123456|  
00000020 37 38 39 0a |789.|

When I run the Gnuradio script for a few seconds, I expect to found  
the following in /tmp/sink:

$ head /tmp/sink  
abcdefghijklmnopqrstuvwxz0123456789  
abcdefghijklmnopqrstuvwxz0123456789  
abcdefghijklmnopqrstuvwxz0123456789  
abcdefghijklmnopqrstuvwxz0123456789  
abcdefghijklmnopqrstuvwxz0123456789  
[…]

However, from time to time, bytes are missing:

$ grep -v abcdefghijklmnopqrstuvwxz0123456789 /tmp/sink  
abcdefghijklmnopqrstuvwxz012qrstuvwxz0123456789  
abcdeqrstuvwxz0123456789  
abcklmnopqrstuvwxz0123456789  
abcdefghijklmnopqrstuvwxz01234stuvwxz0123456789  
abcdefghijklmnopqrstuvwx

Am I doing something wrong ?

Thank you very much for your feedback.

Regards,  
Jerome

---

<div class="post-metadata">

**Author:** ![JSSrSSme\_Nokin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@JSSrSSme\_Nokin](https://www.ruby-forum.com/u/JSSrSSme_Nokin)\
**Post date:** [July 2, 2014, 9:34am UTC](https://www.ruby-forum.com/t/message-queues-inconsistent-data-problem/230681/2 "2014-07-02T09:34:17Z")

</div>

Hello again,

My python code is actually inspired from “Packet Encoder” block  
(/path/to/gnuradio/…/grc\_gnuradio/blks2/packet.py) were I suffer  
from the same issue.  
I wrote that python script to make it very simple/short and confirm  
the troubles.

I would be honored if someone could get a try on it to confirm whether  
or not it is reproducible.  
I’m wondering if the bug is in GnuRadio or between the chair and the  
screen…

Thank you very much !  
Jerome

2014-06-29 16:08 GMT+02:00 Jérôme Nokin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![JSSrSSme\_Nokin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@JSSrSSme\_Nokin](https://www.ruby-forum.com/u/JSSrSSme_Nokin)\
**Post date:** [July 6, 2014, 4:20pm UTC](https://www.ruby-forum.com/t/message-queues-inconsistent-data-problem/230681/3 "2014-07-06T16:20:46Z")

</div>

On Wed, Jul 2, 2014 at 3:33 AM, Jérôme Nokin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I’m wondering if the bug is in GnuRadio or between the chair and the  
> screen..
> 
> Thank you very much !  
> Jerome

My best guess is that you are flooding the queueing system and it’s  
dropping on you. Try increasing the depth of the queue.

Also, message queues aren’t well supported, which is why no one is  
answering your questions. Probably best to think of another way to  
handle  
your problem (like the new async message passing system:  
[http://gnuradio.org/doc/doxygen/page\_msg\_passing.html](http://gnuradio.org/doc/doxygen/page_msg_passing.html))

Tom

---

<div class="post-metadata">

**Author:** ![JSSrSSme\_Nokin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@JSSrSSme\_Nokin](https://www.ruby-forum.com/u/JSSrSSme_Nokin)\
**Post date:** [July 6, 2014, 4:58pm UTC](https://www.ruby-forum.com/t/message-queues-inconsistent-data-problem/230681/4 "2014-07-06T16:58:17Z")

</div>

Thank you for your advices Tom,

Regards,  
Jerome

2014-07-06 16:18 GMT+02:00 Tom R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
