Interrupting a simple GNUradio flow
<p>I'm experimenting with writing GNUradio scripts in python.  My eventual goal is to have a routine that periodically writes a floating point result from within a GNUradio process to the serial port.  As a first step I wanted to simply pause a simple routine  The following code plays a 1kHz tone thru the sound card:  </p>

<pre><code>`#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: simpleTone
# Generated: Wed Jun 29 07:26:02 2016
##################################################

from gnuradio import analog
from gnuradio import audio
from gnuradio import blocks
from gnuradio import gr
import time

class simpleTone(gr.top_block):

    def __init__(self):
    gr.top_block.__init__(self)

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate)
        self.audio_sink_0 = audio.sink(samp_rate, "", True)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.audio_sink_0, 0))


if __name__ == '__main__':
    simpleTone().run()`
</code></pre>

<p>The code above works fine, with the exception of some overflows and clicking in the audio.  However if I make the following substitution:  </p>

<pre><code>`        
if __name__ == '__main__':
    simpleTone().start()
    time.sleep(3)
    simpleTone().stop()`
</code></pre>

<p>The result is that the file runs, and does end after 3 seconds but no audio is produced.</p>

<p>I'm sure I've missed something fairly basic, any help would be appreciated.  Thanks.</p>

<p>-Ed</p>