Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI FGs: returning WORK_DONE doesn't shut down the FG #6723

Open
willcode opened this issue Jun 16, 2023 · 2 comments
Open

GUI FGs: returning WORK_DONE doesn't shut down the FG #6723

willcode opened this issue Jun 16, 2023 · 2 comments

Comments

@willcode
Copy link
Member

willcode commented Jun 16, 2023

What happened?

Returning -1 from work() in a Python Embedded Block does not terminate the flowgraph. Possibly something wrong with the PyBind11 inheritance tree?

The enums here

py::enum_<gr::block::work_return_t>(m, "work_return_t")

(based on)
enum work_return_t { WORK_CALLED_PRODUCE = -2, WORK_DONE = -1 };

Can not be returned here

Error:

thread_body_wrapper :error: ERROR thread[thread-per-block[0]: <block EPB: File Source to Tagged Stream(3)>]: TypeError: '>' not supported between instances of 'gnuradio.gr.gr_python.work_return_t' and 'int'

At:
  /dcs/lib/python3.10/site-packages/gnuradio/gr/gateway.py(303): consume_items
  /dcs/lib/python3.10/site-packages/gnuradio/gr/gateway.py(200): handle_general_work

System Information

Any

GNU Radio Version

3.11-git (main)

Specific Version

No response

Steps to Reproduce the Problem

Return gr.WORK_DONE from a Python block.

Relevant log output

No response

@willcode
Copy link
Member Author

willcode commented Jun 16, 2023

@mormj Any clue why returning -1 from an EPB does not terminate the flowgraph, or print the "we're done" message in block_executor.cc? Is this a PyBind11 inheritance problem? I can't see how it all fits together.

@ryanvolz It looks like you might be familiar with this area too.

It turns out that GUI flowgraphs don't shut down (the graphics at least) on DONE. This has nothing to do with Python. Returning -1 from a EPB does shut down a non-GUI flowgraph as expected.

@marcusmueller marcusmueller changed the title Python Gateway: work return code enums do not match return type of general_work GUI FGs: returning WORK_DONE doesn't shut down the FG Feb 14, 2024
@marcusmueller
Copy link
Member

Can reproduce:

repro6723

import numpy as np
from gnuradio import gr

class blk(gr.sync_block):  # other base classes are basic_block, decim_block, interp_block
    def __init__(self):  # only default arguments here
        gr.sync_block.__init__(
            self,
            name='instant return -1 block',   # will show up in GRC
            in_sig=[np.complex64],
            out_sig=[]
        )

    def work(self, input_items, output_items):
        return -1

happily keeps that window open.
https://gist.github.com/marcusmueller/901bf36bbb0e52929a8db9a0b23d7e62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants