-
-
Notifications
You must be signed in to change notification settings - Fork 610
Async get_events
, handle_event
, handle_readables
, handle_writables
#769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 24 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
8d87f7e
Asynchronous `handle_event` and `LocalExecutor` thread
abhinavsingh dbaf18a
Bail out on first task completion
abhinavsingh 40e38cb
mypy
abhinavsingh e0fd4de
Add `helper/benchmark.sh` and fix threaded which must now use asyncio…
abhinavsingh f5998dd
Print open file diff from `benchmark.sh`
abhinavsingh d5ef5fd
Add `--local-executor` flag, disabled by default for now until tests …
abhinavsingh aad066b
Async `handle_readables` and `handle_writables` for `HttpProtocolHand…
abhinavsingh b25b041
Async `get_events`
abhinavsingh f0042de
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 2d311a6
Address tests after async changes
abhinavsingh 416d852
mypy and flake8
abhinavsingh c71f91f
spelldoc
abhinavsingh 94f9ef8
`check.py` and trailing comma
abhinavsingh ae089f4
Rename to `_assertions.py`
abhinavsingh b3fb2bd
Merge branch 'async-handle-events' of github.com:abhinavsingh/proxy.p…
abhinavsingh 2a727c8
Add missing `pytest-mock` and `pytest-asyncio` deps
abhinavsingh c03c817
Add `pytest-mock` to `pylint` deps
abhinavsingh 78b59aa
Correct use of `parameterize` and add `PT007` to flake8 ignores
abhinavsingh 55d3a29
Fix mypy hints broken for `< Python3.9`
abhinavsingh 87ff921
Remove usage of `asynccontextmanager` which is not available for all …
abhinavsingh 9436e99
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 39eebc4
Fix for pre-python-3.9 versions
abhinavsingh f0d4357
Merge branch 'async-handle-events' of github.com:abhinavsingh/proxy.p…
abhinavsingh d89160c
`AsyncTask` apis `set_name` and `get_name` are not available on all s…
abhinavsingh 0543b54
Install setuptools via `lib-dep` until we recommend editable install
abhinavsingh cbd2be2
Deprecate support for `Python 3.6`
abhinavsingh 0c30899
Use recommendation suggested here https://github.com/abhinavsingh/pro…
abhinavsingh 5348b0a
Address recommendation here https://github.com/abhinavsingh/proxy.py/…
abhinavsingh 5dd0926
Make `Threadless` agnostic of `multiprocessing.Process`
abhinavsingh 3b8019d
Acceptors must dispatch to local executor in non-blocking fashion
abhinavsingh 3e7ddec
No daemon for executor processes and fix shutdown logic
abhinavsingh 1c746e6
Only return fds from `_selected_events` not all events data
abhinavsingh 1f4c176
Refactor logic
abhinavsingh 91741a7
Prefix private methods with `_`
abhinavsingh 3044758
`work_queue` and not `client_queue`
abhinavsingh 5b04f42
Turn `Threadless` into an abstract executor. Introduce `RemoteExecutor`
abhinavsingh 36dcbc1
Make `LocalExecutor` agnostic of `threading.Thread`
abhinavsingh 271652c
`LocalExecutor` now implements `Threadless`
abhinavsingh 194ce58
`get_events` and `get_descriptors` now must return int and not sock. …
abhinavsingh 01d5121
Fix `main` tests
abhinavsingh 473fe8c
Apply suggestions from code review
abhinavsingh 466530c
Merge branch 'async-handle-events' of github.com:abhinavsingh/proxy.p…
abhinavsingh baff0b9
Apply code review recommendations manually
abhinavsingh c5ed3e3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 15966ac
Revert back `Any` and use `addr or None`
abhinavsingh b870038
Merge branch 'async-handle-events' of github.com:abhinavsingh/proxy.p…
abhinavsingh 292ea7a
Merge branch 'develop' into async-handle-events
abhinavsingh cedf02d
Address `flake8`
abhinavsingh d96d5c2
Update tests to use `fileno`
abhinavsingh 2805841
Fix doc build
abhinavsingh 7d5e955
Fix doc spell, use tear down and not teardown
abhinavsingh 71a595e
Merge branch 'develop' into async-handle-events
abhinavsingh f36ab2d
Doc updates
abhinavsingh f78fe5e
Add back support for `Python 3.6`
abhinavsingh d158d67
Merge branch 'async-handle-events' of github.com:abhinavsingh/proxy.p…
abhinavsingh 265380d
Acceptors dont need loop initialization
abhinavsingh 5684b8c
On Python 3.6 `asyncio.new_event_loop()` is necessary
abhinavsingh 8686093
Make doc happy
abhinavsingh d84d3b4
`--threaded` needs a new event loop for 3.7 too
abhinavsingh 7090764
Always use `asyncio.new_event_loop()` for threaded mode
abhinavsingh bb0ae7c
Lint fixes
abhinavsingh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/bash | ||
# | ||
# proxy.py | ||
# ~~~~~~~~ | ||
# ⚡⚡⚡ Fast, Lightweight, Programmable, TLS interception capable | ||
# proxy server for Application debugging, testing and development. | ||
# | ||
# :copyright: (c) 2013-present by Abhinav Singh and contributors. | ||
# :license: BSD, see LICENSE for more details. | ||
# | ||
usage() { | ||
echo "Usage: ./helper/benchmark.sh" | ||
echo "You must run this script from proxy.py repo root." | ||
} | ||
|
||
DIRNAME=$(dirname "$0") | ||
if [ "$DIRNAME" != "./helper" ]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
BASENAME=$(basename "$0") | ||
if [ "$BASENAME" != "benchmark.sh" ]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
PWD=$(pwd) | ||
if [ $(basename $PWD) != "proxy.py" ]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
TIMEOUT=1 | ||
QPS=8000 | ||
CONCURRENCY=100 | ||
TOTAL_REQUESTS=100000 | ||
OPEN_FILE_LIMIT=65536 | ||
BACKLOG=OPEN_FILE_LIMIT | ||
PID_FILE=/tmp/proxy.pid | ||
|
||
ulimit -n $OPEN_FILE_LIMIT | ||
|
||
# time python -m \ | ||
# proxy \ | ||
# --enable-web-server \ | ||
# --plugin proxy.plugin.WebServerPlugin \ | ||
# --backlog $BACKLOG \ | ||
# --open-file-limit $OPEN_FILE_LIMIT \ | ||
# --pid-file $PID_FILE \ | ||
# --log-file /dev/null | ||
|
||
PID=$(cat $PID_FILE) | ||
if [[ -z "$PID" ]]; then | ||
echo "Either pid file doesn't exist or no pid found in the pid file" | ||
exit 1 | ||
fi | ||
ADDR=$(lsof -Pan -p $PID -i | grep -v COMMAND | awk '{ print $9 }') | ||
|
||
PRE_RUN_OPEN_FILES=$(./helper/monitor_open_files.sh) | ||
|
||
echo "CONCURRENCY: $CONCURRENCY workers, TOTAL REQUESTS: $TOTAL_REQUESTS req, QPS: $QPS req/sec, TIMEOUT: $TIMEOUT sec" | ||
hey \ | ||
-n $TOTAL_REQUESTS \ | ||
-c $CONCURRENCY \ | ||
-q $QPS \ | ||
-t $TIMEOUT \ | ||
http://$ADDR/http-route-example | ||
|
||
POST_RUN_OPEN_FILES=$(./helper/monitor_open_files.sh) | ||
|
||
echo $output | ||
|
||
echo "Open files diff:" | ||
diff <( echo "$PRE_RUN_OPEN_FILES" ) <( echo "$POST_RUN_OPEN_FILES" ) | ||
|
||
# while true; do netstat -ant | grep .8899 | awk '{print $6}' | sort | uniq -c | sort -n; sleep 1; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# proxy.py | ||
# ~~~~~~~~ | ||
# ⚡⚡⚡ Fast, Lightweight, Programmable, TLS interception capable | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.