`--inactive-conn-cleanup-timeout` (#1504)

* `--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>
This commit is contained in:
Abhinav Singh 2024-11-14 18:31:45 +05:30 committed by GitHub
parent 050ac1c39a
commit 8d81b1426f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 1 deletions

View File

@ -2619,6 +2619,7 @@ usage: -m [-h] [--tunnel-hostname TUNNEL_HOSTNAME] [--tunnel-port TUNNEL_PORT]
[--tunnel-ssh-key-passphrase TUNNEL_SSH_KEY_PASSPHRASE] [--tunnel-ssh-key-passphrase TUNNEL_SSH_KEY_PASSPHRASE]
[--tunnel-remote-port TUNNEL_REMOTE_PORT] [--threadless] [--tunnel-remote-port TUNNEL_REMOTE_PORT] [--threadless]
[--threaded] [--num-workers NUM_WORKERS] [--enable-events] [--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] [--enable-proxy-protocol] [--enable-conn-pool] [--key-file KEY_FILE]
[--cert-file CERT_FILE] [--client-recvbuf-size CLIENT_RECVBUF_SIZE] [--cert-file CERT_FILE] [--client-recvbuf-size CLIENT_RECVBUF_SIZE]
[--server-recvbuf-size SERVER_RECVBUF_SIZE] [--server-recvbuf-size SERVER_RECVBUF_SIZE]
@ -2682,6 +2683,16 @@ options:
--enable-events Default: False. Enables core to dispatch lifecycle --enable-events Default: False. Enables core to dispatch lifecycle
events. Plugins can be used to subscribe for core events. Plugins can be used to subscribe for core
events. 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 --enable-proxy-protocol
Default: False. If used, will enable proxy protocol. Default: False. If used, will enable proxy protocol.
Only version 1 is currently supported. Only version 1 is currently supported.

View File

@ -20,6 +20,7 @@ from typing import (
cast, cast,
) )
from ...common.flag import flags as proxy_flags
from ...common.types import Readables, Writables, SelectableEvents from ...common.types import Readables, Writables, SelectableEvents
from ...common.logger import Logger from ...common.logger import Logger
from ...common.constants import ( from ...common.constants import (
@ -37,6 +38,20 @@ T = TypeVar('T')
logger = logging.getLogger(__name__) 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]): class Threadless(ABC, Generic[T]):
"""Work executor base class. """Work executor base class.
@ -87,7 +102,7 @@ class Threadless(ABC, Generic[T]):
SelectableEvents, SelectableEvents,
] = {} ] = {}
self.wait_timeout: float = DEFAULT_WAIT_FOR_TASKS_TIMEOUT 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 self._total: int = 0
# When put at the top, causes circular import error # When put at the top, causes circular import error
# since integrated ssh tunnel was introduced. # since integrated ssh tunnel was introduced.