[CalendarServer-changes] [6750] CalendarServer/trunk/contrib/performance/speedcenter.tac

source_changes at macosforge.org source_changes at macosforge.org
Tue Jan 18 07:41:25 PST 2011


Revision: 6750
          http://trac.macosforge.org/projects/calendarserver/changeset/6750
Author:   exarkun at twistedmatrix.com
Date:     2011-01-18 07:41:17 -0800 (Tue, 18 Jan 2011)
Log Message:
-----------
Use a dedicated WSGI threadpool with only 1 thread to avoid the unexplained segfaults.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/speedcenter.tac

Modified: CalendarServer/trunk/contrib/performance/speedcenter.tac
===================================================================
--- CalendarServer/trunk/contrib/performance/speedcenter.tac	2011-01-18 01:07:33 UTC (rev 6749)
+++ CalendarServer/trunk/contrib/performance/speedcenter.tac	2011-01-18 15:41:17 UTC (rev 6750)
@@ -14,19 +14,36 @@
 # limitations under the License.
 ##
 
+import os
+
+from twisted.python.threadpool import ThreadPool
 from twisted.python.modules import getModule
-from twisted.application.service import Application
+from twisted.application.service import Application, Service
 from twisted.application.internet import TCPServer
 from twisted.web.server import Site
 from twisted.web.wsgi import WSGIResource
 from twisted.internet import reactor
 
+class ThreadService(Service):
+    def __init__(self):
+        self.pool = ThreadPool(minthreads=0, maxthreads=1)
+
+    def startService(self):
+        self.pool.start()
+
+    def stopService(self):
+        self.pool.stop()
+
+
 speedcenter = getModule("speedcenter").filePath
 django = speedcenter.sibling("wsgi").child("django.wsgi")
 namespace = {"__file__": django.path}
 execfile(django.path, namespace, namespace)
 
+threads = ThreadService()
 application = Application("SpeedCenter")
-resource = WSGIResource(reactor, reactor.getThreadPool(), namespace["application"])
-site = Site(resource, 'httpd.log')
-TCPServer(8000, site).setServiceParent(application)
+threads.setServiceParent(application)
+
+resource = WSGIResource(reactor, threads.pool, namespace["application"])
+site = Site(resource) # , 'httpd.log')
+TCPServer(int(os.environ.get('PORT', 8000)), site).setServiceParent(application)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110118/c2f94dd6/attachment.html>


More information about the calendarserver-changes mailing list