Yes, you can arbitrarily rearrange the flow graph and I've written code that does it much like you show. What you specifically have to do in order for changes to take effect is to precede them with self.lock()
and follow with self.unlock()
. (Note that lock/unlock pairs cannot be nested.) I don't recall offhand whether stopping and starting will have the same effect.
I have met quite a few block-specific quirks, for example:
hier_block2.disconnect_all
breaks the block's inputs and outputs, but individual disconnect
s work fine. (Now fixed.)
- On Mac OS X, the
audio.source
and audio.sink
stop working after the first restart or unlock. (Being fixed.)
blocks.throttle
's timer runs continuously (so if you take it out for a while and put it back in later, it will run too fast until it catches up).
However, these can all be worked around and they are problems with specific blocks' implementations, not the basic concept of reconfiguring the flow graph. I have yet to encounter any problem which is inherent to reconfiguring in general.
(It may well be the case that the stream_selector
mentioned in HokieTux's answer is faster and more reliable for the cases it can handle, but I felt I should report that arbitrary reconfiguration is an option.)