Skip to content

Commit

Permalink
--inactive-conn-cleanup-timeout (#1504)
Browse files Browse the repository at this point in the history
* `--inactive-conn-cleanup-timeout`

* Specify default in docs

* Update README

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Clarify usecase is comments

* Lint

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
abhinavsingh and pre-commit-ci[bot] authored Nov 14, 2024
1 parent 050ac1c commit 8d81b14
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2619,6 +2619,7 @@ usage: -m [-h] [--tunnel-hostname TUNNEL_HOSTNAME] [--tunnel-port TUNNEL_PORT]
[--tunnel-ssh-key-passphrase TUNNEL_SSH_KEY_PASSPHRASE]
[--tunnel-remote-port TUNNEL_REMOTE_PORT] [--threadless]
[--threaded] [--num-workers NUM_WORKERS] [--enable-events]
[--inactive-conn-cleanup-timeout INACTIVE_CONN_CLEANUP_TIMEOUT]
[--enable-proxy-protocol] [--enable-conn-pool] [--key-file KEY_FILE]
[--cert-file CERT_FILE] [--client-recvbuf-size CLIENT_RECVBUF_SIZE]
[--server-recvbuf-size SERVER_RECVBUF_SIZE]
Expand Down Expand Up @@ -2682,6 +2683,16 @@ options:
--enable-events Default: False. Enables core to dispatch lifecycle
events. Plugins can be used to subscribe for core
events.
--inactive-conn-cleanup-timeout INACTIVE_CONN_CLEANUP_TIMEOUT
Time after which inactive works must be cleaned up.
Increase this value if your backend services are slow
to response or when proxy.py is handling a high
volume. When running proxy.py on Google Cloud (GCP)
you may see 'backend_connection_closed_before_data_sen
t_to_client', with curl clients you may see 'Empty
reply from server' error when '--inactive-conn-
cleanup-timeout' value is low for your use-case.
Default 1 seconds
--enable-proxy-protocol
Default: False. If used, will enable proxy protocol.
Only version 1 is currently supported.
Expand Down
17 changes: 16 additions & 1 deletion proxy/core/work/threadless.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
cast,
)

from ...common.flag import flags as proxy_flags
from ...common.types import Readables, Writables, SelectableEvents
from ...common.logger import Logger
from ...common.constants import (
Expand All @@ -37,6 +38,20 @@
logger = logging.getLogger(__name__)


proxy_flags.add_argument(
'--inactive-conn-cleanup-timeout',
default=DEFAULT_INACTIVE_CONN_CLEANUP_TIMEOUT,
help='Time after which inactive works must be cleaned up. '
+ 'Increase this value if your backend services are slow to response '
+ 'or when proxy.py is handling a high volume. When running proxy.py on Google Cloud (GCP) '
+ "you may see 'backend_connection_closed_before_data_sent_to_client', with curl clients "
+ "you may see 'Empty reply from server' error when '--inactive-conn-cleanup-timeout' "
+ 'value is low for your use-case. Default {0} seconds'.format(
DEFAULT_INACTIVE_CONN_CLEANUP_TIMEOUT,
),
)


class Threadless(ABC, Generic[T]):
"""Work executor base class.
Expand Down Expand Up @@ -87,7 +102,7 @@ def __init__(
SelectableEvents,
] = {}
self.wait_timeout: float = DEFAULT_WAIT_FOR_TASKS_TIMEOUT
self.cleanup_inactive_timeout: float = DEFAULT_INACTIVE_CONN_CLEANUP_TIMEOUT
self.cleanup_inactive_timeout: float = self.flags.inactive_conn_cleanup_timeout
self._total: int = 0
# When put at the top, causes circular import error
# since integrated ssh tunnel was introduced.
Expand Down

0 comments on commit 8d81b14

Please sign in to comment.