Friday, May 3, 2024

Lifecycle of flowgraph?

Hey,

 

I’m debugging a devious issue, which I suspect to be a bug in either UHD or the UHD USRP Sink, but before I write the proper bug report I wanted to check with the pros if I’m using GNURadio correctly in the first place.

 

Tl;dr: how do I properly and fully close/destroy a flowgraph from Python, without killing the Python instance?

 

I’m creating a flowgraph from a Python loop, execute it, and destroy it. I’ve tried the following ideas: call stop and wait, then either set reference variable to None, or calling the destructor explicitly – essentially this:

 

<begin loop>

tb = top_block_constructor(<…>)

tb.start()

[…]

tb.stop()

tb.wait()

tb = None  # OR:

del tb     # Neither of this works as I would expect

<end loop>

 

The main problem I’m encountering is that the flow graph is not fully torn down and recreated in each iteration, instead it appears to keep _some_ parts referenced. The easiest way to see this is by setting one of the block’s minoutbuf variables to a nonzero value and observe the log output. At a certain point, this may look like this (emphasis mine)

 

selector :info: set_min_output_buffer on block 12665 to 16360

 

the following loop iteration it is

 

selector :info: set_min_output_buffer on block 12678 to 16360

 

For my flowgraph, which is pretty simple, this leads to a reproducible Python interpreter(!) crash after 1002-1004 iterations:

 

selector :info: set_min_output_buffer on block 13016 to 16360

interleaved_short_to_complex :info: set_min_output_buffer on block 13018 to 56000000

Fatal Python error: _PyGILState_NoteThreadState: Couldn't create autoTSSkey mapping

Python runtime state: initialized

 

Thread 0x00007eff7ffff700 (most recent call first):

  <no Python frame>

 

Thread 0x00007f01b366a740 (most recent call first):

  File "/home/<username>/radioconda/lib/python3.11/threading.py", line 629 in wait

  File "/home/<username>/radioconda/lib/python3.11/threading.py", line 969 in start

  File "/home/<username>/rfitester/ClientBase.py", line 68 in run

  File "/home/<username>/radioconda/lib/python3.11/threading.py", line 327 in wait

  File "/home/<username>/rfitester/./RFIController.py", line 160 in <module>

[1]    629642 abort      ./RFIController.py <CLI parameters>

 

Thanks for your help!

 

Med vennlig hilsen

Adrian Winter
Forsker
SINTEF Digital
Sustainable Communication Technologies
 

M: +4793862207 
E: adrian.winter@sintef.no

 

Trondheim  | Oslo  | Bergen  | Tromsø  | Narvik  | Mo i Rana  | Steinkjer  | Verdal  | Ã…lesund  | Raufoss  | Kongsberg  | Porsgrunn  | Arendal  | Hirtshals  | Brussel


Teknologi for et bedre samfunn
 
 

 

No comments:

Post a Comment