Skip to content

Commit f08757a

Browse files
authored
feat: restore gunicorn worker default configs from 3.5.0 (#326)
* feat: restore defaults present < 3.6.0, but retain customizability * revert the test, too * also restore this assert :) --------- Co-authored-by: Jeremy Fehr <[email protected]>
1 parent 2e7de92 commit f08757a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/functions_framework/_http/gunicorn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class GunicornApplication(gunicorn.app.base.BaseApplication):
2121
def __init__(self, app, host, port, debug, **options):
2222
self.options = {
2323
"bind": "%s:%s" % (host, port),
24-
"workers": os.environ.get("WORKERS", (os.cpu_count() or 1) * 4),
25-
"threads": os.environ.get("THREADS", 1),
26-
"timeout": os.environ.get("CLOUD_RUN_TIMEOUT_SECONDS", 300),
24+
"workers": os.environ.get("WORKERS", 1),
25+
"threads": os.environ.get("THREADS", (os.cpu_count() or 1) * 4),
26+
"timeout": os.environ.get("CLOUD_RUN_TIMEOUT_SECONDS", 0),
2727
"loglevel": "error",
2828
"limit_request_line": 0,
2929
}

tests/test_http.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,17 @@ def test_gunicorn_application(debug):
9797
assert gunicorn_app.app == app
9898
assert gunicorn_app.options == {
9999
"bind": "%s:%s" % (host, port),
100-
"workers": os.cpu_count() * 4,
101-
"threads": 1,
102-
"timeout": 300,
100+
"workers": 1,
101+
"threads": os.cpu_count() * 4,
102+
"timeout": 0,
103103
"loglevel": "error",
104104
"limit_request_line": 0,
105105
}
106106

107107
assert gunicorn_app.cfg.bind == ["1.2.3.4:1234"]
108-
assert gunicorn_app.cfg.workers == os.cpu_count() * 4
109-
assert gunicorn_app.cfg.threads == 1
110-
assert gunicorn_app.cfg.timeout == 300
108+
assert gunicorn_app.cfg.workers == 1
109+
assert gunicorn_app.cfg.threads == os.cpu_count() * 4
110+
assert gunicorn_app.cfg.timeout == 0
111111
assert gunicorn_app.load() == app
112112

113113

0 commit comments

Comments
 (0)