Skip to content

Commit 0a9b9a0

Browse files
Use --local-executor flag by default for Docker container (#880)
* Benchmark gets packaged within wheel if set as a package * Use `--local-executor` flag by default for Docker containers * Dockerfile update * Fix mypy issues * Remove conflicting dir names * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 798faca commit 0a9b9a0

File tree

12 files changed

+39
-78
lines changed

12 files changed

+39
-78
lines changed

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,7 @@ RUN apk update && apk add openssl
2626

2727
EXPOSE 8899/tcp
2828
ENTRYPOINT [ "proxy" ]
29-
CMD [ "--hostname=0.0.0.0" ]
29+
CMD [ \
30+
"--hostname=0.0.0.0" \
31+
"--local-executor" \
32+
]

benchmark/__init__.py

Lines changed: 0 additions & 10 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

benchmark/_proxy.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
proxy.py
4+
~~~~~~~~
5+
⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on
6+
Network monitoring, controls & Application development, testing, debugging.
7+
8+
:copyright: (c) 2013-present by Abhinav Singh and contributors.
9+
:license: BSD, see LICENSE for more details.
10+
"""
11+
import time
12+
import ipaddress
13+
import proxy
14+
15+
16+
if __name__ == '__main__':
17+
with proxy.Proxy(
18+
['--plugin', 'proxy.plugin.WebServerPlugin'],
19+
hostname=ipaddress.ip_address('127.0.0.1'),
20+
port=8899,
21+
backlog=65536,
22+
open_file_limit=65536,
23+
enable_web_server=True,
24+
disable_proxy_server=False,
25+
num_acceptors=10,
26+
local_executor=True,
27+
log_file='/dev/null',
28+
) as _:
29+
while True:
30+
try:
31+
time.sleep(1)
32+
except KeyboardInterrupt:
33+
break
File renamed without changes.
File renamed without changes.

benchmark/aiohttp/__init__.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

benchmark/blacksheep/__init__.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

benchmark/compare.sh

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ run_benchmark() {
6161
}
6262

6363
benchmark_lib() {
64-
python ./benchmark/$1/server.py > /dev/null 2>&1 &
64+
python ./benchmark/_$1.py > /dev/null 2>&1 &
6565
local SERVER_PID=$!
6666
echo "Server (pid:$SERVER_PID) running"
6767
sleep 1
@@ -75,31 +75,6 @@ benchmark_lib() {
7575
fi
7676
}
7777

78-
benchmark_proxy_py() {
79-
python -m proxy \
80-
--hostname 127.0.0.1 \
81-
--port $1 \
82-
--backlog 65536 \
83-
--open-file-limit 65536 \
84-
--enable-web-server \
85-
--plugin proxy.plugin.WebServerPlugin \
86-
--disable-http-proxy \
87-
--num-acceptors 10 \
88-
--local-executor \
89-
--log-file /dev/null > /dev/null 2>&1 &
90-
local SERVER_PID=$!
91-
echo "Server (pid:$SERVER_PID) running"
92-
sleep 1
93-
run_benchmark $1
94-
kill -15 $SERVER_PID
95-
sleep 1
96-
kill -0 $SERVER_PID > /dev/null 2>&1
97-
local RUNNING=$?
98-
if [ "$RUNNING" == "1" ]; then
99-
echo "Server gracefully shutdown"
100-
fi
101-
}
102-
10378
benchmark_asgi() {
10479
uvicorn \
10580
--port $1 \
@@ -120,7 +95,7 @@ benchmark_asgi() {
12095

12196
# echo "============================="
12297
# echo "Benchmarking Proxy.Py"
123-
# benchmark_proxy_py $PROXYPY_PORT
98+
# PYTHONPATH=. benchmark_lib proxy $PROXYPY_PORT
12499
# echo "============================="
125100

126101
# echo "============================="

benchmark/starlette/__init__.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

benchmark/tornado/__init__.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)