Python, ASP/IIS, KeyboardInterrupt

Jim Abrams jim at publishingresources.com
Tue Apr 24 10:03:00 EDT 2001


I've been using Python to power my ASP pages and have come across this 
dreaded KeyboardInterrupt error. After searching through archives it seems 
that this is still an unanswered problem with the Ctrl-C handler?

Well it's been a becoming more of a problem lately so I tried to work around 
it and this is what I came up with, any comments and help is greatly 
appreciated.

import signal
def noOp(a,b): pass
signal.signal(signal.SIGINT, noOp)

To me this looks damn ugly, but I suppose its better than getting errors in 
production services.

Oh and for some reason the special handler value signal.SIG_IGN didn't work, 
kept getting errors as the it tried to run the handler (which is just an 
int).

However I need to set this signal handler in the main thread, so my first 
question becomes... how can I tell from within a threaded program which is 
the main thread? Is there some function I can't seem to find?

If I toss some code into Application_OnStart is that gauranteed to run in 
the main thread?

Also if anyone has a better idea what do to with the SIGINT instead of 
ignoring it that would help too.








More information about the Python-list mailing list