Python, ASP/IIS, KeyboardInterrupt 
Author Message
 Python, ASP/IIS, KeyboardInterrupt

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.



Sat, 11 Oct 2003 22:03:00 GMT  
 Python, ASP/IIS, KeyboardInterrupt

Quote:

> 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.

This is possibly/hopefully fixed in win32all-139 and ActivePython 210.

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

If the problem is what I suspect, and have witnessed using xpcom, then
the interrupt signal is sent at some time other than when Python is
executing, but Python's signal handler sees it anyway and sets it
pending.  When Python is next called, this pending exception is then
thrown and the COM call fails.

So if this is indeed the case, then ignoring it is reasonable as it is
not Python code that was interrupted!  And if it is not the case, my fix
in the builds referenced above will not be a fix at all!

Mark.



Sat, 11 Oct 2003 22:48:25 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. using com object written in python from iis/asp

2. IIS ASP Python 2.2 script works first time only

3. config for Python as the IIS hosted ASP script Lang

4. ideal architecture for Python/IIS/ASP/COM?

5. connect to IIS and debug ASP with python????

6. IIS + ASP + <#@Language=Python#>== performance_hit

7. Python + IIS/ASP questions (modules, namespaces, etc)

8. Trouble with IIS Python ASP

9. KeyboardInterrupt in IIS?

10. KeyboardInterrupt errors in ASP pages

11. KeyboardInterrupt exception in ASP pages.

12. KeyboardInterrupt in ASP

 

 
Powered by phpBB® Forum Software