Does a block always *have* to return something?

Hi

Will something like this in the work function be correct?

self.consume(0, len(input_items[0])
if (something):
return
else:
out[:] = in0 ** 2 #example
return len(output_items[0])

When I say return nothing I mean, the block just flushes the data that
it consumed and waits on the next samples.

Thanks
Anil

Hi Anil,

Does a block always have to return something?
What you mean is the work function. I know this is a bit nit-picky, but
there has always been a lot of confusion caused by exactly that: The
block is the whole instance of a class derived from gr.block, and the
work() (or general_work()) is the method of that class which gets called
repeatedly at runtime. You can have state as properties of the instance.

I’m not quite sure what the effect of returning None (which is what
happens when you don’t return something in python) is, because that
NoneObject would then be handled through SWIF to C++, and I have no idea
whether SWIG has a uniform way of converting NoneObjects to integers.

In essence: yes, general_work() must always return a number, but in most
cases it’s totally O.K. to return 0 if your block wasn’t able to produce
output.

Best regards,
Marcus

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs