[cpif] r167 - trunk/frontend-web
svn at argo.es
svn at argo.es
Tue Jun 19 19:13:53 CEST 2007
Author: jcea
Date: Tue Jun 19 19:13:45 2007
New Revision: 167
Log:
Gestion de varias conexiones HTTP activas simultaneamente.
Modified:
trunk/frontend-web/globales.py
trunk/frontend-web/servidor_web.py
trunk/frontend-web/skins.py
Modified: trunk/frontend-web/globales.py
==============================================================================
--- trunk/frontend-web/globales.py (original)
+++ trunk/frontend-web/globales.py Tue Jun 19 19:13:45 2007
@@ -17,3 +17,7 @@
# Permitimos el acceso anonimo al foro
allow_anonymous=True
+
+# Simultaneous HTTP connections
+http_max_clients=16
+
Modified: trunk/frontend-web/servidor_web.py
==============================================================================
--- trunk/frontend-web/servidor_web.py (original)
+++ trunk/frontend-web/servidor_web.py Tue Jun 19 19:13:45 2007
@@ -1,9 +1,32 @@
# $Id$
-from globales import monitor,allow_anonymous
+from globales import monitor,allow_anonymous,http_max_clients
urls={}
+class ThreadingMixIn(object) :
+ def __init__(self,num_threads=16) :
+ import threading,Queue
+ self._queue=Queue.Queue()
+ for i in xrange(num_threads) :
+ t=threading.Thread(target=self._thread)
+ t.setDaemon(True)
+ t.start()
+ del t
+
+ def _thread(self) :
+ while True :
+ request,client_addr=self._queue.get()
+ try :
+ self.finish_request(request, client_addr)
+ self.close_request(request)
+ except:
+ self.handle_error(request, client_addr)
+ self.close_request(request)
+
+ def process_request(self,request,client_addr) :
+ self._queue.put((request,client_addr))
+
def servidor_web() :
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
@@ -59,7 +82,12 @@
def do_POST(self) :
return self.do_GET()
- httpd=HTTPServer(("",8877),handler)
+ class threadHTTPServer(ThreadingMixIn,HTTPServer) :
+ def __init__(self,*args) :
+ ThreadingMixIn.__init__(self,num_threads=http_max_clients)
+ HTTPServer.__init__(self,*args)
+
+ httpd=threadHTTPServer(("",8877),handler)
httpd.serve_forever()
def calcula_urls() :
Modified: trunk/frontend-web/skins.py
==============================================================================
--- trunk/frontend-web/skins.py (original)
+++ trunk/frontend-web/skins.py Tue Jun 19 19:13:45 2007
@@ -71,7 +71,6 @@
self._tz = pytz.timezone("Europe/Madrid")
self._skin = "default"
self._path = url
- print url
self._url = "/%s" % url[0]
self._style = ["odd","even"]
self._text = []
More information about the cpif
mailing list