Skip to content

Commit ff89d6f

Browse files
committed
✨ Allow specifying the thread counts.
1 parent 8bea060 commit ff89d6f

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/kubernetes_wsgi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.1"
1+
__version__ = "1.2"

src/kubernetes_wsgi/__main__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,28 @@ def parse_args(argv: Sequence[Text]) -> Dict[str, Any]:
4646
default="/healthz",
4747
help="URL path to the health check endpoint",
4848
)
49+
parser.add_argument(
50+
"--min-threads",
51+
metavar="N",
52+
type=int,
53+
default=5,
54+
help="Minimum number of threads to run",
55+
)
56+
parser.add_argument(
57+
"--max-threads",
58+
metavar="N",
59+
type=int,
60+
default=20,
61+
help="Maximum number of threads to run",
62+
)
4963
args = parser.parse_args(argv)
5064
return {
5165
"application": args.application,
5266
"port": args.port,
5367
"metrics_port": args.metrics_port,
5468
"health_check_path": args.health_check_path,
69+
"min_threads": args.min_threads,
70+
"max_threads": args.max_threads,
5571
}
5672

5773

src/kubernetes_wsgi/server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def serve(
5151
metrics_port: int = 9000,
5252
access_log_formatter: LogFormatter = proxiedLogFormatter,
5353
health_check_path: str = "/healthz",
54+
min_threads: int = 5,
55+
max_threads: int = 20,
5456
):
5557
# Quiet the Twisted factory logging.
5658
Factory.noisy = False
@@ -63,7 +65,9 @@ def serve(
6365
)
6466

6567
# Create the server.
66-
pool = threadpool.ThreadPool()
68+
pool = threadpool.ThreadPool(
69+
minthreads=min_threads, maxthreads=max_threads
70+
)
6771
reactor.callWhenRunning(pool.start)
6872
_listen_wsgi(
6973
reactor,

0 commit comments

Comments
 (0)