Skip to content
This repository has been archived by the owner on Feb 20, 2018. It is now read-only.

Commit

Permalink
Increase ThreadPool thread count maximum to 50
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Zubov authored and Stanislav Zubov committed Nov 10, 2015
1 parent 729bdfe commit cd4eacd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,6 @@ class Config(object):
SELENIUM_PORT = 4455
VMMASTER_AGENT_PORT = 9000

THREAD_POOL_MAX = 100

LOG_LEVEL = "INFO"
2 changes: 2 additions & 0 deletions tests/unit/data/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ class Config(object):
SELENIUM_PORT = 4455
VMMASTER_AGENT_PORT = 9000

THREAD_POOL_MAX = 100

LOG_LEVEL = "INFO"
2 changes: 2 additions & 0 deletions tests/unit/data/config_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ class Config(object):
SELENIUM_PORT = 4455
VMMASTER_AGENT_PORT = 9000

THREAD_POOL_MAX = 100

LOG_LEVEL = "INFO"
2 changes: 2 additions & 0 deletions tests/unit/data/config_with_preloaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ class Config(object):
SELENIUM_PORT = 4455
VMMASTER_AGENT_PORT = 9000

THREAD_POOL_MAX = 100

LOG_LEVEL = "INFO"
11 changes: 8 additions & 3 deletions vmmaster/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
from twisted.web.server import Site
from twisted.web.resource import Resource
from twisted.internet import defer
from twisted.python.threadpool import ThreadPool
from app import create_app

from http_proxy import ProxyResource, HTTPChannelWithClient
from core.logger import log
from core.config import config


def _block_on(d, timeout=None):
Expand Down Expand Up @@ -48,9 +50,11 @@ class VMMasterServer(object):
def __init__(self, reactor, port):
self.reactor = reactor
self.app = create_app()
wsgi_resource = WSGIResource(self.reactor,
self.reactor.getThreadPool(),
self.app)

self.thread_pool = ThreadPool(maxthreads=config.THREAD_POOL_MAX)
self.thread_pool.start()
wsgi_resource = WSGIResource(self.reactor, self.thread_pool, self.app)

root_resource = RootResource(wsgi_resource)
root_resource.putChild("proxy", ProxyResource(self.app))
site = Site(root_resource)
Expand All @@ -68,6 +72,7 @@ def __del__(self):
d = self.bind.stopListening()
_block_on(d, 20)
self.app.cleanup()
self.thread_pool.stop()

def wait_for_end_active_sessions(self):
active_sessions = self.app.sessions.active()
Expand Down

0 comments on commit cd4eacd

Please sign in to comment.