Skip to content

Commit

Permalink
feat: restore gunicorn worker default configs from 3.5.0 (#326)
Browse files Browse the repository at this point in the history
* feat: restore defaults present < 3.6.0, but retain customizability

* revert the test, too

* also restore this assert :)

---------

Co-authored-by: Jeremy Fehr <jfehrforgithub2@gmail.com>
  • Loading branch information
jrmfg and jrmfg authored May 16, 2024
1 parent 2e7de92 commit f08757a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/functions_framework/_http/gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class GunicornApplication(gunicorn.app.base.BaseApplication):
def __init__(self, app, host, port, debug, **options):
self.options = {
"bind": "%s:%s" % (host, port),
"workers": os.environ.get("WORKERS", (os.cpu_count() or 1) * 4),
"threads": os.environ.get("THREADS", 1),
"timeout": os.environ.get("CLOUD_RUN_TIMEOUT_SECONDS", 300),
"workers": os.environ.get("WORKERS", 1),
"threads": os.environ.get("THREADS", (os.cpu_count() or 1) * 4),
"timeout": os.environ.get("CLOUD_RUN_TIMEOUT_SECONDS", 0),
"loglevel": "error",
"limit_request_line": 0,
}
Expand Down
12 changes: 6 additions & 6 deletions tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ def test_gunicorn_application(debug):
assert gunicorn_app.app == app
assert gunicorn_app.options == {
"bind": "%s:%s" % (host, port),
"workers": os.cpu_count() * 4,
"threads": 1,
"timeout": 300,
"workers": 1,
"threads": os.cpu_count() * 4,
"timeout": 0,
"loglevel": "error",
"limit_request_line": 0,
}

assert gunicorn_app.cfg.bind == ["1.2.3.4:1234"]
assert gunicorn_app.cfg.workers == os.cpu_count() * 4
assert gunicorn_app.cfg.threads == 1
assert gunicorn_app.cfg.timeout == 300
assert gunicorn_app.cfg.workers == 1
assert gunicorn_app.cfg.threads == os.cpu_count() * 4
assert gunicorn_app.cfg.timeout == 0
assert gunicorn_app.load() == app


Expand Down

0 comments on commit f08757a

Please sign in to comment.