diff --git a/README.md b/README.md index 3bf8ce98d8..5c6f30978f 100644 --- a/README.md +++ b/README.md @@ -2238,7 +2238,7 @@ usage: -m [-h] [--tunnel-hostname TUNNEL_HOSTNAME] [--tunnel-port TUNNEL_PORT] [--filtered-url-regex-config FILTERED_URL_REGEX_CONFIG] [--cloudflare-dns-mode CLOUDFLARE_DNS_MODE] -proxy.py v2.4.0rc7.dev12+gd234339.d20220116 +proxy.py v2.4.0rc7.dev15+gc4ea34e options: -h, --help show this help message and exit @@ -2279,13 +2279,13 @@ options: Default: None. Unix socket path to use. When provided --host and --port flags are ignored --local-executor LOCAL_EXECUTOR - Default: 1. Enabled by default. Use 0 to disable. When - enabled acceptors will make use of local (same - process) executor instead of distributing load across - remote (other process) executors. Enable this option - to achieve CPU affinity between acceptors and - executors, instead of using underlying OS kernel - scheduling algorithm. + Default: 1. Enabled by default (except on Windows). + Use 0 to disable. When enabled acceptors will make use + of local (same process) executor instead of + distributing load across remote (other process) + executors. Enable this option to achieve CPU affinity + between acceptors and executors, instead of using + underlying OS kernel scheduling algorithm. --num-acceptors NUM_ACCEPTORS Defaults to number of CPU cores. --version, -v Prints proxy.py version. diff --git a/proxy/common/constants.py b/proxy/common/constants.py index 37ef452f54..a828ab0cf4 100644 --- a/proxy/common/constants.py +++ b/proxy/common/constants.py @@ -122,7 +122,7 @@ def _env_threadless_compliant() -> bool: DEFAULT_STATIC_SERVER_DIR = os.path.join(PROXY_PY_DIR, "public") DEFAULT_MIN_COMPRESSION_LIMIT = 20 # In bytes DEFAULT_THREADLESS = _env_threadless_compliant() -DEFAULT_LOCAL_EXECUTOR = True +DEFAULT_LOCAL_EXECUTOR = not IS_WINDOWS DEFAULT_TIMEOUT = 10.0 DEFAULT_VERSION = False DEFAULT_HTTP_PORT = 80 diff --git a/proxy/core/acceptor/acceptor.py b/proxy/core/acceptor/acceptor.py index d83c5e00ae..af6ef73478 100644 --- a/proxy/core/acceptor/acceptor.py +++ b/proxy/core/acceptor/acceptor.py @@ -42,7 +42,7 @@ type=int, default=int(DEFAULT_LOCAL_EXECUTOR), help='Default: ' + ('1' if DEFAULT_LOCAL_EXECUTOR else '0') + '. ' + - 'Enabled by default. Use 0 to disable. When enabled acceptors ' + + 'Enabled by default (except on Windows). Use 0 to disable. When enabled acceptors ' + 'will make use of local (same process) executor instead of distributing load across ' + 'remote (other process) executors. Enable this option to achieve CPU affinity between ' + 'acceptors and executors, instead of using underlying OS kernel scheduling algorithm.', diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index 6acee8ee71..6a76ad29ed 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -37,52 +37,76 @@ def _tls_interception_flags(ca_cert_suffix: str = '') -> str: )) -PROXY_PY_FLAGS_INTEGRATION = ( - ('--threadless'), +_PROXY_PY_FLAGS_INTEGRATION = [ ('--threadless --local-executor 0'), - ('--threaded'), -) - -PROXY_PY_HTTPS = ( - ('--threadless ' + _https_server_flags()), +] +if not IS_WINDOWS: + _PROXY_PY_FLAGS_INTEGRATION += [ + ('--threadless'), + ('--threaded'), + ] +PROXY_PY_FLAGS_INTEGRATION = tuple(_PROXY_PY_FLAGS_INTEGRATION) + +_PROXY_PY_HTTPS = [ ('--threadless --local-executor 0 ' + _https_server_flags()), - ('--threaded ' + _https_server_flags()), -) - -PROXY_PY_FLAGS_TLS_INTERCEPTION = ( - ('--threadless ' + _tls_interception_flags()), +] +if not IS_WINDOWS: + _PROXY_PY_HTTPS += [ + ('--threadless ' + _https_server_flags()), + ('--threaded ' + _https_server_flags()), + ] +PROXY_PY_HTTPS = tuple(_PROXY_PY_HTTPS) + +_PROXY_PY_FLAGS_TLS_INTERCEPTION = [ ('--threadless --local-executor 0 ' + _tls_interception_flags()), - ('--threaded ' + _tls_interception_flags()), -) - -PROXY_PY_FLAGS_MODIFY_CHUNK_RESPONSE_PLUGIN = ( - ( - '--threadless --plugin proxy.plugin.ModifyChunkResponsePlugin ' + - _tls_interception_flags('-chunk') - ), +] +if not IS_WINDOWS: + _PROXY_PY_FLAGS_TLS_INTERCEPTION += [ + ('--threadless ' + _tls_interception_flags()), + ('--threaded ' + _tls_interception_flags()), + ] +PROXY_PY_FLAGS_TLS_INTERCEPTION = tuple(_PROXY_PY_FLAGS_TLS_INTERCEPTION) + +_PROXY_PY_FLAGS_MODIFY_CHUNK_RESPONSE_PLUGIN = [ ( '--threadless --local-executor 0 --plugin proxy.plugin.ModifyChunkResponsePlugin ' + _tls_interception_flags('-chunk') ), - ( - '--threaded --plugin proxy.plugin.ModifyChunkResponsePlugin ' + - _tls_interception_flags('-chunk') - ), +] +if not IS_WINDOWS: + _PROXY_PY_FLAGS_MODIFY_CHUNK_RESPONSE_PLUGIN += [ + ( + '--threadless --plugin proxy.plugin.ModifyChunkResponsePlugin ' + + _tls_interception_flags('-chunk') + ), + ( + '--threaded --plugin proxy.plugin.ModifyChunkResponsePlugin ' + + _tls_interception_flags('-chunk') + ), + ] +PROXY_PY_FLAGS_MODIFY_CHUNK_RESPONSE_PLUGIN = tuple( + _PROXY_PY_FLAGS_MODIFY_CHUNK_RESPONSE_PLUGIN, ) -PROXY_PY_FLAGS_MODIFY_POST_DATA_PLUGIN = ( - ( - '--threadless --plugin proxy.plugin.ModifyPostDataPlugin ' + - _tls_interception_flags('-post') - ), +_PROXY_PY_FLAGS_MODIFY_POST_DATA_PLUGIN = [ ( '--threadless --local-executor 0 --plugin proxy.plugin.ModifyPostDataPlugin ' + _tls_interception_flags('-post') ), - ( - '--threaded --plugin proxy.plugin.ModifyPostDataPlugin ' + - _tls_interception_flags('-post') - ), +] +if not IS_WINDOWS: + _PROXY_PY_FLAGS_MODIFY_POST_DATA_PLUGIN += [ + ( + '--threaded --plugin proxy.plugin.ModifyPostDataPlugin ' + + _tls_interception_flags('-post') + ), + ( + '--threadless --plugin proxy.plugin.ModifyPostDataPlugin ' + + _tls_interception_flags('-post') + ), + ] +PROXY_PY_FLAGS_MODIFY_POST_DATA_PLUGIN = tuple( + _PROXY_PY_FLAGS_MODIFY_POST_DATA_PLUGIN, )