2003-07-04 14:24:44 +00:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
2000-03-08 12:01:51 +00:00
|
|
|
# sz_fcgi.py - Multithreaded FastCGI Wrapper
|
2004-08-16 19:20:53 +00:00
|
|
|
"""Multithreaded FastCGI Wrapper"""
|
2000-03-08 12:01:51 +00:00
|
|
|
|
2004-07-07 18:04:40 +00:00
|
|
|
import thread
|
2004-08-16 19:20:53 +00:00
|
|
|
|
2004-07-07 18:04:40 +00:00
|
|
|
import linkcheck.fcgi
|
2000-03-08 12:01:51 +00:00
|
|
|
|
|
|
|
|
|
2004-08-16 19:20:53 +00:00
|
|
|
class SzFcgi (object):
|
|
|
|
|
"""create threads to handle cgi requests"""
|
|
|
|
|
|
2004-07-07 18:04:40 +00:00
|
|
|
def __init__ (self, func):
|
2004-08-16 19:20:53 +00:00
|
|
|
"""store function to execute on a request"""
|
2000-03-24 19:00:30 +00:00
|
|
|
self.func = func
|
|
|
|
|
|
2004-07-07 18:04:40 +00:00
|
|
|
def run (self):
|
2004-08-16 19:20:53 +00:00
|
|
|
"""create a new thread to handle requests"""
|
|
|
|
|
try:
|
2004-07-07 18:04:40 +00:00
|
|
|
while linkcheck.fcgi.isFCGI():
|
|
|
|
|
req = linkcheck.fcgi.FCGI()
|
2004-08-16 19:20:53 +00:00
|
|
|
thread.start_new_thread(self.func, (self, req))
|
|
|
|
|
except:
|
2000-03-26 18:53:23 +00:00
|
|
|
import traceback
|
2004-01-29 19:04:49 +00:00
|
|
|
traceback.print_exc(file=file('traceback', 'a'))
|