Using a signal to terminate a programm running with an asyncore loop

david at quanterium.zzn.com david at quanterium.zzn.com
Fri Feb 8 19:12:03 EST 2008


On Feb 8, 4:03 pm, Larry Bates <larry.ba... at websafe.com> wrote:
> When signal is caught handle_shutdown_signal is called.  At that point
> SHUTDOWN_PERFORMED will ALWAYS be False.  Normally all you do in this function
> is to set SHUTDOWN_PERFORMED to True and have a test somewhere in your main
> program loop that tests if SHUTDOWN_PERFORMED:...  I know that when you reach
>
> if not SHUTDOWN_PERFORMED:
>
> SHUTDOWN_PERFORMED will always be False so #do some stuff will get executed.
>
> Setting SHUTDOWN_PERFORMED = True doesn't do any good unless you catch this back
> in the main program.
>
> If I were you I would try to issue kill from console first to see if it works.
> Then try os.kill().
>
> Hope this helps some.
>
> -Larry

I won't have a chance to try your suggestions until next week.  Though
I'm not convinced that handle_shutdown_signal is even getting called,
since I'm not seeing the diagnostic print statement, neither on the
console nor where stdout/stderr is being redirected.  I did try using
the kill command from the console to issue SIGTERM to the process
(e.g. kill -s SIGTERM <pid>) and I still got the infinite series of
"warning: unhandled exception" messages.

- David



More information about the Python-list mailing list