mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
add --threads param
This commit is contained in:
parent
e42859492c
commit
7349c4fb9a
@ -91,11 +91,21 @@ class Config(object):
|
|||||||
@property
|
@property
|
||||||
def worker_class(self):
|
def worker_class(self):
|
||||||
uri = self.settings['worker_class'].get()
|
uri = self.settings['worker_class'].get()
|
||||||
|
|
||||||
|
## are we using a threaded worker?
|
||||||
|
is_sync = uri.endswith('SyncWorker') or uri == 'sync'
|
||||||
|
if is_sync and self.threads > 1:
|
||||||
|
uri = "gunicorn.workers.gthread.ThreadedWorker"
|
||||||
|
|
||||||
worker_class = util.load_class(uri)
|
worker_class = util.load_class(uri)
|
||||||
if hasattr(worker_class, "setup"):
|
if hasattr(worker_class, "setup"):
|
||||||
worker_class.setup()
|
worker_class.setup()
|
||||||
return worker_class
|
return worker_class
|
||||||
|
|
||||||
|
@property
|
||||||
|
def threads(self):
|
||||||
|
return self.settings['threads'].get()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def workers(self):
|
def workers(self):
|
||||||
return self.settings['workers'].get()
|
return self.settings['workers'].get()
|
||||||
@ -550,6 +560,27 @@ class WorkerClass(Setting):
|
|||||||
can also load the gevent class with ``egg:gunicorn#gevent``
|
can also load the gevent class with ``egg:gunicorn#gevent``
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
class WorkerThreads(Setting):
|
||||||
|
name = "threads"
|
||||||
|
section = "Worker Processes"
|
||||||
|
cli = ["--threads"]
|
||||||
|
meta = "INT"
|
||||||
|
validator = validate_pos_int
|
||||||
|
type = int
|
||||||
|
default = 1
|
||||||
|
desc = """\
|
||||||
|
The number of worker threads for handling requests.
|
||||||
|
|
||||||
|
Run each worker in prethreaded mode with the specified number of
|
||||||
|
threads per worker.
|
||||||
|
|
||||||
|
A positive integer generally in the 2-4 x $(NUM_CORES) range. You'll
|
||||||
|
want to vary this a bit to find the best for your particular
|
||||||
|
application's work load.
|
||||||
|
|
||||||
|
If it is not defined, the default is 1.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class WorkerConnections(Setting):
|
class WorkerConnections(Setting):
|
||||||
name = "worker_connections"
|
name = "worker_connections"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user