changeset 134:037a600884b1

Add threadpool options to Paste factories. #59
author Allan Saddi <allan@saddi.com>
date Mon, 04 Apr 2011 23:02:16 -0700
parents d75c21b506bb
children aab3e8c8f5c1
files ChangeLog flup/server/paste_factory.py
diffstat 2 files changed, 35 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/ChangeLog	Sat Feb 19 00:16:45 2011 -0800
     1.2 +++ b/ChangeLog	Mon Apr 04 23:02:16 2011 -0700
     1.3 @@ -1,3 +1,7 @@
     1.4 +2011-04-04  Allan Saddi  <allan@saddi.com>
     1.5 +
     1.6 +	* Add threadpool options to Paste factories.
     1.7 +
     1.8  2011-02-19  Allan Saddi  <allan@saddi.com>
     1.9  
    1.10  	* When deriving PATH_INFO from REQUEST_URI, take SCRIPT_NAME into account.
     2.1 --- a/flup/server/paste_factory.py	Sat Feb 19 00:16:45 2011 -0800
     2.2 +++ b/flup/server/paste_factory.py	Mon Apr 04 23:02:16 2011 -0700
     2.3 @@ -30,18 +30,26 @@
     2.4  
     2.5  def run_ajp_thread(wsgi_app, global_conf,
     2.6                     scriptName='', host='localhost', port='8009',
     2.7 -                   allowedServers='127.0.0.1', debug=NoDefault):
     2.8 +                   allowedServers='127.0.0.1', debug=NoDefault,
     2.9 +                   minSpare=None, maxSpare=None, maxThreads=None):
    2.10      import flup.server.ajp
    2.11      addr = (host, int(port))
    2.12      if debug is NoDefault:
    2.13          debug = global_conf.get('debug', False)
    2.14      debug = asbool(debug)
    2.15 +    threadpool_args = {}
    2.16 +    if minSpare is not None:
    2.17 +        threadpool_args['minSpare'] = int(minSpare)
    2.18 +    if maxSpare is not None:
    2.19 +        threadpool_args['maxSpare'] = int(maxSpare)
    2.20 +    if maxThreads is not None:
    2.21 +        threadpool_args['maxThreads'] = int(maxThreads)
    2.22      s = flup.server.ajp.WSGIServer(
    2.23          wsgi_app,
    2.24          scriptName=scriptName,
    2.25          bindAddress=addr,
    2.26          allowedServers=aslist(allowedServers),
    2.27 -        debug=debug,
    2.28 +        debug=debug, **threadpool_args
    2.29          )
    2.30      s.run()
    2.31  
    2.32 @@ -76,7 +84,8 @@
    2.33  def run_fcgi_thread(wsgi_app, global_conf,
    2.34                      host=None, port=None,
    2.35                      socket=None, umask=None,
    2.36 -                    multiplexed=False, debug=NoDefault):
    2.37 +                    multiplexed=False, debug=NoDefault,
    2.38 +                    minSpare=None, maxSpare=None, maxThreads=None):
    2.39      import flup.server.fcgi
    2.40      if socket:
    2.41          assert host is None and port is None
    2.42 @@ -91,11 +100,19 @@
    2.43      if debug is NoDefault:
    2.44          debug = global_conf.get('debug', False)
    2.45      debug = asbool(debug)
    2.46 +    threadpool_args = {}
    2.47 +    if minSpare is not None:
    2.48 +        threadpool_args['minSpare'] = int(minSpare)
    2.49 +    if maxSpare is not None:
    2.50 +        threadpool_args['maxSpare'] = int(maxSpare)
    2.51 +    if maxThreads is not None:
    2.52 +        threadpool_args['maxThreads'] = int(maxThreads)
    2.53      s = flup.server.fcgi.WSGIServer(
    2.54          wsgi_app,
    2.55          bindAddress=sock, umask=umask,
    2.56          multiplexed=asbool(multiplexed),
    2.57 -        debug=debug)
    2.58 +        debug=debug, **threadpool_args
    2.59 +        )
    2.60      s.run()
    2.61  
    2.62  def run_fcgi_fork(wsgi_app, global_conf,
    2.63 @@ -139,18 +156,26 @@
    2.64  def run_scgi_thread(wsgi_app, global_conf,
    2.65                      scriptName=NoDefault, host='localhost', port='4000',
    2.66                      allowedServers='127.0.0.1',
    2.67 -                    debug=NoDefault):
    2.68 +                    debug=NoDefault,
    2.69 +                    minSpare=None, maxSpare=None, maxThreads=None):
    2.70      import flup.server.scgi
    2.71      addr = (host, int(port))
    2.72      if debug is NoDefault:
    2.73          debug = global_conf.get('debug', False)
    2.74      debug = asbool(debug)
    2.75 +    threadpool_args = {}
    2.76 +    if minSpare is not None:
    2.77 +        threadpool_args['minSpare'] = int(minSpare)
    2.78 +    if maxSpare is not None:
    2.79 +        threadpool_args['maxSpare'] = int(maxSpare)
    2.80 +    if maxThreads is not None:
    2.81 +        threadpool_args['maxThreads'] = int(maxThreads)
    2.82      s = flup.server.scgi.WSGIServer(
    2.83          wsgi_app,
    2.84          scriptName=scriptName,
    2.85          bindAddress=addr,
    2.86          allowedServers=aslist(allowedServers),
    2.87 -        debug=debug,
    2.88 +        debug=debug, **threadpool_args
    2.89          )
    2.90      s.run()
    2.91