discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] KeyboardInterrupt not being caught in top_block


From: Eric Blossom
Subject: Re: [Discuss-gnuradio] KeyboardInterrupt not being caught in top_block
Date: Fri, 18 Jun 2010 11:03:46 -0700
User-agent: Mutt/1.5.20 (2009-08-17)

On Fri, Jun 18, 2010 at 06:14:55PM +1000, Kyle Zhou wrote:
> 
> On 18/06/2010, at 2:56 AM, Eric Blossom wrote:
> > 
> > Kyle,
> > 
> > Are you trying to set a handler for a signal somewhere in your code?
> > If so, it's unlikely to work.  In general signals and threads don't
> > play together well.  A bit of googling will show you the mine field.
> > 
> > If you're trying to catch a std::exception, that should work fine.
> > 
> > Eric
> 
> Hi Eric
> I did not set any handler except 'except KeyboardInterrupt: ...'
> I tried it on Ubuntu as well which turned out to fail.
> Yes, I agree with you that it's likely the problem of coworking of signals 
> and threads.
> I tried a single threaded program where the same mechanism did work.
> So I will change my approach completely.
> Thanks for making things clarified.
> Kyle

Kyle,

I just spent a few minutes reviewing the guts of the code.  We do all
the magic to detect ^C in python, and then just tell the flow graph to
stop cleanly and wait for it to finish.  We do not propagate the
python exception since it's often times caught "in the wrong thread".

Summary: the built in behavior is to map ^C (SIGINT) into code that
stops the graph.  That code is very tricky, took a long time to get
working reliably, and I suggest you don't mess with it.  However, if
you're curious, see gnuradio-core/src/python/gnuradio/gr/top_block.py
and gnuradio-core/src/lib/runtime/gr_top_block.i

Eric



reply via email to

[Prev in Thread] Current Thread [Next in Thread]