Skip to content

Commit 9dc35e8

Browse files
committed
fix: avoid mutating options dict in Gunicorn applications
Create a copy of the options dict before modifying it to prevent side effects when the same options dict is reused elsewhere. This could cause issues with timeout tests.
1 parent 7134c91 commit 9dc35e8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/functions_framework/_http/gunicorn.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class GunicornApplication(BaseGunicornApplication):
6060

6161
def __init__(self, app, host, port, debug, **options):
6262
threads = int(os.environ.get("THREADS", (os.cpu_count() or 1) * 4))
63+
# Make a copy to avoid mutating the passed-in options dict
64+
options = dict(options)
6365
options["threads"] = threads
6466

6567
super().__init__(app, host, port, debug, **options)
@@ -87,5 +89,6 @@ class UvicornApplication(BaseGunicornApplication):
8789
"""Gunicorn application for ASGI apps using Uvicorn workers."""
8890

8991
def __init__(self, app, host, port, debug, **options):
92+
options = dict(options)
9093
options["worker_class"] = "uvicorn_worker.UvicornWorker"
9194
super().__init__(app, host, port, debug, **options)

0 commit comments

Comments
 (0)