use tabs instead of spaces
[plcapi.git] / ModPython.py
index 2f46b17..07a0fda 100644 (file)
@@ -5,10 +5,10 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 #
 # Copyright (C) 2004-2006 The Trustees of Princeton University
-# $Id: ModPython.py,v 1.2 2006/10/25 21:05:05 mlhuang Exp $
 #
 
 import sys
+import time
 import traceback
 import xmlrpclib
 from mod_python import apache
@@ -45,6 +45,10 @@ def handler(req):
         # Handle request
         response = api.handle(remote_addr, request)
 
+        # Shut down database connection, otherwise up to MaxClients DB
+        # connections will remain open.
+        api.db.close()
+
         # Write response
         req.content_type = "text/xml; charset=" + api.encoding
         req.send_http_header()
@@ -52,7 +56,8 @@ def handler(req):
 
         return apache.OK
 
-    except:
+    except Exception, err:
         # Log error in /var/log/httpd/(ssl_)?error_log
-        print >> log, traceback.format_exc()
+        t = "[" + time.ctime() + "] [error]"
+        print >> log, t, err, traceback.format_exc()
         return apache.HTTP_INTERNAL_SERVER_ERROR