OK, it does work, as long as there is a message port defined and connected in a flowgraph. I was trying too simple an example. You would do your thread management in the start() and stop() functions.
"""
Embedded Python Blocks:
Each time this file is saved, GRC will instantiate the first class it finds
to get ports and parameters of your block. The arguments to __init__ will
be the parameters. All of them are required to have default values!
"""
import numpy as np
from gnuradio import gr
import pmt
class blk(gr.sync_block): # other base classes are basic_block, decim_block, interp_block
"""Embedded Python Block example - a simple multiply const"""
def __init__(self): # only default arguments here
"""arguments to this function show up as parameters in GRC"""
gr.sync_block.__init__(
self,
name='Embedded Python Block', # will show up in GRC
in_sig=[],
out_sig=[]
)
self.message_port_register_out(pmt.intern("msgout"))
print('init')
def start(self):
print('start')
return True
def stop(self):
print('stop')
return True