changed start_server to accept a number of threads... still defaults to 1 though
This commit is contained in:
parent
c8f24334d0
commit
deab81483e
3 changed files with 8 additions and 8 deletions
|
@ -78,13 +78,13 @@ class DjangoContext(Vows.Context):
|
|||
|
||||
class DjangoHTTPContext(DjangoContext):
|
||||
|
||||
def start_server(self, host=None, port=None, settings={}):
|
||||
def start_server(self, host=None, port=None, settings={}, threads=1):
|
||||
if not port: port = DEFAULT_PORT
|
||||
if not host: host = DEFAULT_HOST
|
||||
|
||||
self.address = (host, port)
|
||||
self.server = DjangoServer(host, port)
|
||||
self.server.start(settings)
|
||||
self.server.start(settings,threads)
|
||||
|
||||
def __init__(self, parent):
|
||||
super(DjangoHTTPContext, self).__init__(parent)
|
||||
|
|
|
@ -16,12 +16,12 @@ from cherrypy import wsgiserver
|
|||
from django.core.handlers.wsgi import WSGIHandler
|
||||
|
||||
|
||||
def run_app(host, port):
|
||||
def run_app(host, port, threadCount):
|
||||
server = wsgiserver.CherryPyWSGIServer(
|
||||
(host, port),
|
||||
WSGIHandler(),
|
||||
server_name='tornado-pyvows',
|
||||
numthreads = 1
|
||||
numthreads = threadCount
|
||||
)
|
||||
|
||||
my_thread = current_thread()
|
||||
|
@ -38,8 +38,8 @@ class DjangoServer(object):
|
|||
self.host = host
|
||||
self.port = port
|
||||
|
||||
def start(self, settings):
|
||||
self.thr = Thread(target=run_app, args=(self.host, self.port))
|
||||
def start(self, settings, threadCount=1):
|
||||
self.thr = Thread(target=run_app, args=(self.host, self.port, threadCount))
|
||||
self.thr.daemon = True
|
||||
self.thr.settings = {}
|
||||
for k, v in settings.iteritems():
|
||||
|
|
|
@ -111,7 +111,7 @@ class ContextTest(Vows.Context):
|
|||
def topic(self):
|
||||
return self.server
|
||||
|
||||
def should_default_to_one_thread(self,topic):
|
||||
def should_allow_user_to_specify_number_of_threads(self,topic):
|
||||
expect(topic.thr.server._get_numthreads()).to_equal(5)
|
||||
|
||||
|
||||
|
|
Reference in a new issue