Dirk Meyer wrote:
> Duncan Webb wrote:
>> Dirk Meyer wrote:
>>> Duncan Webb wrote:
>>>> I have this in __main__, so I would expect the Ctrl-C exit
>>>> (basically the stop command) to print something.
>>>> |try:
>>>> |    main()
>>>> |except Exception, why:
>>>> |    traceback.print_exc()
>>>> |    print why
>>>> |print 'done.'
>>> You will not see print why because SystemExit will be handled
>>> internally and kaa.main.run would just stop without exception. But you
>>> should see 'done'
>> Exactly what happens
> 
> So it is working :)
> 
>>> Looking at current rel-1:
>>>
>>> | try:
>>> |     # signal handler
>>> |     signal.signal(signal.SIGTERM, signal_handler)
>>> |     signal.signal(signal.SIGINT, signal_handler)
>>> | |     [...]
>>> | |     kaa.main.run()
>>> | | | except KeyboardInterrupt:
>>> |     print 'Shutdown by keyboard interrupt'
>>> |     # Shutdown the application
>>> |     shutdown()
>>> | | except SystemExit:
>>> |     pass
>>> | | except Exception, e:
>>> |     _debug_('Crash!: %s' % (e), config.DCRITICAL)
>>>
>>> Please remove the signal handler here, let kaa base handle this. You
>>> will also _never_ see 'Shutdown by keyboard interrupt' because kaa
>>> handles this as well. If you want to clean up on shutdown, either
>>> register a callback to kaa.main.siganls['shutdown'] or do this after
>>> all exception handling. BTW, you will also never run into except
>>> SystemExit.
>> I've added some prints into notifier main and the signal handler never
>> gets called, after pressing ctrl-c.
>>
>> What happens is that the signal handler is installed at the very
>> beginning of the program. This is before DirectFB is started and I
>> guess that DirectFB installed it's own signal handlers and the last
>> installed signal handler is used first so DirectFB exits before kaa
>> has seen the ctrl-c.
> 
> Which signal handler? Yours (see above) or the one from kaa main?
> 
>> Freevo runs twice at start up, so it looks like the kaa signal handler
>> is not being installed
> 
> That could be a thread somehow.


At last after lots of frustration, this problem has been solved.

I was being caused by three problems

1) We need the Unix signal handlers because DirectFB is being loaded 
after kaa has set up it's signal handlers and DirectFB replaced the 
signal handlers with it's own version. The Freevo Unix handler only 
needs to raise a SystemExit, which is then caught by kaa.

2) The MPD (Music player daemon) was starting a thread, which was not 
being killed by it's shutdown() method. This was fixed by using the 
thread self destroying method I found at 
http://www.thescripts.com/forum/thread45247.html

3) Correct the kaa 'shutdown' signal handler. Use the correct method 
with no arguments instead of the unix handler method.

After these fixes all is hunky dory, Ctrl-C shuts down Freevo normally 
and the normal shutdown and autoshutdown Freevo work too.

Thanks dischi for your help. It means that the 1.8.0 release can go 
ahead as planned.

Duncan

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to