launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06650
[Merge] lp:~rvb/maas/maas-longpoll-threaded-server into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/maas-longpoll-threaded-server into lp:maas with lp:~rvb/maas/maas-longpoll-rabbitpublisher as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rvb/maas/maas-longpoll-threaded-server/+merge/97053
This branch is a simple hack to support multithreading in the dev server; this is useful to test longpoll. Note that this is the default in Django 1.4 so once we upgrade to Django 1.4, we will be able to remove that code.
--
https://code.launchpad.net/~rvb/maas/maas-longpoll-threaded-server/+merge/97053
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/maas-longpoll-threaded-server into lp:maas.
=== modified file 'src/maasserver/management/commands/runserver.py'
--- src/maasserver/management/commands/runserver.py 2012-02-08 09:05:36 +0000
+++ src/maasserver/management/commands/runserver.py 2012-03-12 16:21:41 +0000
@@ -11,8 +11,13 @@
__metaclass__ = type
__all__ = ['Command']
+from optparse import make_option
+from SocketServer import ThreadingMixIn
+
from django.conf import settings
from django.core.management.commands.runserver import BaseRunserverCommand
+from django.core.servers import basehttp
+from django.core.servers.basehttp import WSGIServer
import oops
from oops_datedir_repo import DateDirRepo
from oops_wsgi import (
@@ -45,6 +50,23 @@
class Command(BaseRunserverCommand):
"""Customized "runserver" command that wraps the WSGI handler."""
+ option_list = BaseRunserverCommand.option_list + (
+ make_option('--threading', action='store_true',
+ dest='use_threading', default=False,
+ help='Use threading for web server.'),
+ )
+
+ def run(self, *args, **options):
+ threading = options.get('use_threading', False)
+ if threading:
+ # This is a simple backport from Django's future
+ # version to support threading.
+ class ThreadedWSGIServer(ThreadingMixIn, WSGIServer):
+ pass
+ # Monkey patch basehttp.WSGIServer.
+ setattr(basehttp, 'WSGIServer', ThreadedWSGIServer)
+
+ return super(Command, self).run(*args, **options)
def get_handler(self, *args, **kwargs):
"""Overridable from `BaseRunserverCommand`: Obtain a WSGI handler."""
Follow ups