Skip to content

Commit 1fb6ff0

Browse files
committed
feat!: enable timeout
default timeout settings is 5 min, same as Cloud run; change default behavior from multi-threads to multi-workesr to avoid zombie timeout settings; allow user customization to workers/threads by assigning env var; noted that timeout won't work when #thread > 1.
1 parent e175553 commit 1fb6ff0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/functions_framework/_http/gunicorn.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ 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": 1,
25-
"threads": (os.cpu_count() or 1) * 4,
26-
"timeout": 0,
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),
2727
"loglevel": "error",
2828
"limit_request_line": 0,
2929
}
3030
self.options.update(options)
3131
self.app = app
32+
3233
super().__init__()
3334

3435
def load_config(self):

0 commit comments

Comments
 (0)