X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=apache%2Fplc.wsgi;h=3e0d51c6e7be5fa14b93a51470a10b4946642651;hb=e70e20fdbececafef842ec7b330fd48db42e614e;hp=e6a7eb3c605d931f66510c33c2b59407bb9b30ef;hpb=502c66df9890a99c0887a3a9c89f7a54fb6914f8;p=plcapi.git diff --git a/apache/plc.wsgi b/apache/plc.wsgi index e6a7eb3c..3e0d51c6 100644 --- a/apache/plc.wsgi +++ b/apache/plc.wsgi @@ -9,11 +9,9 @@ import sys sys.path.append('/usr/share/plc_api') sys.stdout = sys.stderr import traceback -from PLC.Debug import log +from PLC.Logger import logger from PLC.API import PLCAPI -api = PLCAPI() - def application(environ, start_response): try: status = '200 OK' @@ -28,6 +26,12 @@ def application(environ, start_response): """ else: + # Thomas Dreibholz + # Note that this function is called within multiple threads! + # "api" MUST be a local variable instead of a global one. + # Otherwise, this causes concurrent accesses to the same + # object within different threads! + api = PLCAPI() api.environ = environ content_type = 'text/xml' ip = environ.get('REMOTE_ADDR') @@ -36,11 +40,11 @@ def application(environ, start_response): # Shut down database connection, otherwise up to MaxClients DB # connections will remain open. api.db.close() - except Exception, err: + except Exception as err: status = '500 Internal Server Error' content_type = 'text/html' output = 'Internal Server Error' - print >> log, err, traceback.format_exc() + logger.exception("INTERNAL ERROR !!") # Write response response_headers = [('Content-type', '%s' % content_type),