[Pythonmac-SIG] PythonCGISlave conflict with SMTPlib? (MacOS 9, Pers. Web Sharing)

Bob Heeter bob@heeter.net
Sat, 19 Aug 2000 20:08:46 -0700


Dear Python Gurus -

I've been lurking on the list for several months while learning python
and building up some hobby-scale code.  I was very happy when the
PythonCGIslave came out, and I've been successfully running CGI applets
under MacOS 9 and Personal Web Sharing.  I want to say up front that
working with Python has been a lot more fun than any other programming
I've done (I'm a physicist by trade and do a fair amount of software
work for my job), but I've run into a problem that has got me stumped.

I had the idea that it would be nice to upgrade the exception
handler in my CGI so that it would email me some kind of notification
whenever a user ran into a bug in the CGI (in addition to logging any
exceptions (bugs) to the errors file).  This would be nice because
(a) I want to fix any bugs promptly, but (b) I don't want to have to
check on the errors file all the time.  I'd used the smtplib calls
frequently in some of my other code, but when I tried to use them
from within the CGI applet, it caused the CGI to freeze up whenever
it tries to send the email.  I had to go and force-quit the CGI.
The CGI works just fine when I comment out the SMTP calls (which go
to an smtp server on the same machine as the web server).
I've tried putting the smtplib calling code in an exception handler
inside my CGI, putting it in the body of the CGI, putting it
in the exception handler inside PythonCGIslave, and (as a test)
putting it in the main code of the PythonCGIslave cgihandler, and even
putting it in the __init__ function of the PythonCGIslave class,
but the CGI applet still crashes every time.

Does anyone have any ideas how I can get past this problem?
Is there something about the way the web server calls the cgi applet
that prevents the SMTP lib calls from working?

The only thing I can think of is to write a separate "monitor"
applet that just watches the CGI's .errors file and emails me
the contents whenever something is written to the file, but that
is an ugly solution.  I'd really like to have the email call
inside the CGI code, and if possible I'd like to solve the problem
in a platform-independent way.

Thanks in advance for everyone's wisdom.  I hope to be able to
contribute back to the list as I get more up to speed, but for now
it looks like I'm mainly a consumer of advice rather than a producer. :)

-- Bob Heeter

Bob Heeter
Livermore, California