Commit Graph

12 Commits

Author SHA1 Message Date
Abhinav Singh 44d72431e3
Async `get_events`, `handle_event`, `handle_readables`, `handle_writables` (#769)
* Asynchronous `handle_event` and `LocalExecutor` thread

* Bail out on first task completion

* mypy

* Add `helper/benchmark.sh` and fix threaded which must now use asyncio (reduced performance of threaded)

* Print open file diff from `benchmark.sh`

* Add `--local-executor` flag, disabled by default for now until tests are updated

* Async `handle_readables` and `handle_writables` for `HttpProtocolHandlerPlugin` interface (doesnt impact proxy/web plugins for now)

* Async `get_events`

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

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

* Address tests after async changes

* mypy and flake8

* spelldoc

* `check.py` and trailing comma

* Rename to `_assertions.py`

* Add missing `pytest-mock` and `pytest-asyncio` deps

* Add `pytest-mock` to `pylint` deps

* Correct use of `parameterize` and add `PT007` to flake8 ignores

* Fix mypy hints broken for `< Python3.9`

* Remove usage of `asynccontextmanager` which is not available for all Python versions that `proxy.py` supports

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

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

* Fix for pre-python-3.9 versions

* `AsyncTask` apis `set_name` and `get_name` are not available on all supported versions

* Install setuptools via `lib-dep` until we recommend editable install

* Deprecate support for `Python 3.6`

* Use recommendation suggested here https://github.com/abhinavsingh/proxy.py/pull/769\#discussion_r753840929

* Address recommendation here https://github.com/abhinavsingh/proxy.py/pull/769\#discussion_r753841906

* Make `Threadless` agnostic of `multiprocessing.Process`

* Acceptors must dispatch to local executor in non-blocking fashion

* No daemon for executor processes and fix shutdown logic

* Only return fds from `_selected_events` not all events data

* Refactor logic

* Prefix private methods with `_`

* `work_queue` and not `client_queue`

* Turn `Threadless` into an abstract executor. Introduce `RemoteExecutor`

* Make `LocalExecutor` agnostic of `threading.Thread`

* `LocalExecutor` now implements `Threadless`

* `get_events` and `get_descriptors` now must return int and not sock.  `Threadless` now avoids repeated register/unregister and instead make use of `selectors.modify`

* Fix `main` tests

* Apply suggestions from code review

Co-authored-by: Sviatoslav Sydorenko <wk@sydorenko.org.ua>

* Apply code review recommendations manually

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

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

* Revert back `Any` and use `addr or None`

* Address `flake8`

* Update tests to use `fileno`

* Fix doc build

* Fix doc spell, use tear down and not teardown

* Doc updates

* Add back support for `Python 3.6`

* Acceptors dont need loop initialization

* On Python 3.6 `asyncio.new_event_loop()` is necessary

* Make doc happy

* `--threaded` needs a new event loop for 3.7 too

* Always use `asyncio.new_event_loop()` for threaded mode

Added e2e integration tests (subprocess & curl) for all modes.

* Lint fixes

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sviatoslav Sydorenko <wk@sydorenko.org.ua>
2021-11-23 15:02:00 +05:30
Sviatoslav Sydorenko fa89944891
Add initial Sphinx docs 2021-11-18 01:36:13 +01:00
Sviatoslav Sydorenko 462624f49e
Expose pre-commit tool hooks execution times (#692) 2021-11-07 04:35:56 +05:30
Sviatoslav Sydorenko 423e9ce0a4
Add a pytest-based test for catching import loops (#678)
Co-authored-by: Abhinav Singh <mailsforabhinav@gmail.com>
2021-11-06 14:37:08 +05:30
Sviatoslav Sydorenko b09d170ada
Add a config for pytest (#680) 2021-11-06 02:39:33 +05:30
Sviatoslav Sydorenko 4b8b6258e3
Collect coverage for `tests/` (#677)
This is necessary to make sure all the tests actually get executed
somewhere and allows finding dead code in this area.
2021-11-05 11:31:23 +00:00
Sviatoslav Sydorenko 752146a14d
Make pytest emit XML coverage (#673)
This patch should make GHA report coverage to codecov properly.
2021-11-05 06:51:59 +05:30
Abhinav Singh 2a9db3a2dc
Update outdated sections of the codebase (#670)
* Remove autopep8, is redundant now after recent CI changes

* Add pyenv .python-version to .gitignore

* Update year

* Add lib-pytest target so that pytest can run in isolation

* Add git-push hook which will also run the lint.

By default now git-pre-commit hook will only run pytest.

* Update outdated sections of README

* Update requirement to match setup.cfg install_requires

* Deprecate proxy.start and TestCase.PROXY_PORT

Proxy port during test is now available as self.PROXY.pool.flags.port.
Also now TestCase utilize ephemeral port strategy instead of
calling get_available_port utility method.

* Rename to git-pre-push

* Ideally public repo dont require CODECOV_TOKEN but codecov integration is broken since introduction of codecov-action@v2 (instead of codecov binary invocation)

* Issue is possibly with codecov@v2 action, fallback to codecov.  See https://github.com/abhinavsingh/proxy.py/runs/4110423084\?check_suite_focus\=true and https://github.com/codecov/uploader/issues/223

* Revert back to v2
2021-11-05 03:11:22 +05:30
Sviatoslav Sydorenko 7c5877b74a
Migrate the pytest invocation to `tox` (#662)
* Fix the `commands` setting in the tox config

* Wire up `pytest` invocations via tox
2021-11-04 17:47:23 +05:30
Sviatoslav Sydorenko 7ae8211fcb
Organize the linting setup around tox+pre-commit (#657)
* Add a no-op check job to GHA for branch protection

This patch adds an "empty" job that depends on all the important ones
making it possible to use just this `check` job in the branch
protection settings. This reduces the maintenance burden by preventing
the need to update these settings on any changes to the job
declarations.

* Add a config for YAMLLint

* Add a config for flake8

* Add an initial auto-generated PyLint config

* Align pylint line length settings in with flake8

* Colorize the pylint report output

* Correct spelling mistakes caught by `codespell`

* Disable all currently violated PyLint rules

* Start managing the linters setup with pre-commit

Co-authored-by: Abhinav Singh <mailsforabhinav@gmail.com>
2021-11-03 18:07:59 +05:30
Sviatoslav Sydorenko 7606c1d495
Add tox envs for building dists via PEP 517 (#647)
* Invoke self-install via PEP517 in the CI

* Add tox envs for building dists via PEP 517

* Add linting dists via tox to GHA

* Upgrade `master` to `develop` in `setup.py`

* Simplify `python_requires` in `setup.py`

* Convert dynamic `setup.py` into static `setup.cfg`
2021-11-02 03:00:00 +05:30
Abhinav Singh 3bd61e0389
Add tox.ini (#208) 2019-12-01 12:57:21 -08:00