Skip to content

Commit 378395a

Browse files
committed
feat(worker): cap local transport connections
1 parent 015f423 commit 378395a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎vgi/worker.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,15 @@ def _run(
15451545
"--idle-timeout",
15461546
help="Self-shutdown after N seconds idle when serving --unix/--tcp.",
15471547
),
1548+
max_connections: int = typer.Option(
1549+
64,
1550+
"--max-connections",
1551+
min=1,
1552+
help=(
1553+
"Maximum concurrent --unix/--tcp connections. Bounds worker file descriptors "
1554+
"and threads while excess clients wait in the socket backlog."
1555+
),
1556+
),
15481557
http_threads: int | None = typer.Option( # noqa: B008
15491558
None,
15501559
"--http-threads",
@@ -1630,6 +1639,7 @@ def _emit(bound: str) -> None:
16301639
server,
16311640
abs_path,
16321641
threaded=True,
1642+
max_connections=max_connections,
16331643
idle_timeout=effective_idle,
16341644
on_bound=_emit,
16351645
)
@@ -1671,6 +1681,7 @@ def _emit_tcp(bound_host: str, bound_port: int) -> None:
16711681
tcp_host,
16721682
tcp_port,
16731683
threaded=True,
1684+
max_connections=max_connections,
16741685
idle_timeout=effective_idle,
16751686
on_bound=_emit_tcp,
16761687
)

0 commit comments

Comments
 (0)