flexexecutor 0.0.9__tar.gz → 0.0.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flexexecutor-0.0.9 → flexexecutor-0.0.11}/PKG-INFO +8 -23
- {flexexecutor-0.0.9 → flexexecutor-0.0.11}/README.md +3 -1
- {flexexecutor-0.0.9 → flexexecutor-0.0.11}/flexexecutor.py +9 -1
- flexexecutor-0.0.11/pyproject.toml +107 -0
- flexexecutor-0.0.9/.github/ISSUE_TEMPLATE/bug_report.md +0 -17
- flexexecutor-0.0.9/.github/ISSUE_TEMPLATE/feature_request.md +0 -14
- flexexecutor-0.0.9/.github/workflows/publish.yml +0 -47
- flexexecutor-0.0.9/.github/workflows/test-suite.yml +0 -36
- flexexecutor-0.0.9/.gitignore +0 -168
- flexexecutor-0.0.9/flexexecutor.egg-info/PKG-INFO +0 -145
- flexexecutor-0.0.9/flexexecutor.egg-info/SOURCES.txt +0 -19
- flexexecutor-0.0.9/flexexecutor.egg-info/dependency_links.txt +0 -1
- flexexecutor-0.0.9/flexexecutor.egg-info/requires.txt +0 -20
- flexexecutor-0.0.9/flexexecutor.egg-info/top_level.txt +0 -1
- flexexecutor-0.0.9/noxfile.py +0 -197
- flexexecutor-0.0.9/pyproject.toml +0 -124
- flexexecutor-0.0.9/setup.cfg +0 -4
- flexexecutor-0.0.9/tests/__init__.py +0 -0
- flexexecutor-0.0.9/tests/conftest.py +0 -27
- flexexecutor-0.0.9/tests/test_async.py +0 -219
- flexexecutor-0.0.9/tests/test_thread.py +0 -204
- {flexexecutor-0.0.9 → flexexecutor-0.0.11}/LICENSE +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: flexexecutor
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.11
|
|
4
4
|
Summary: Executors for both async and sync functions and automatically scales the number of workers
|
|
5
|
+
Home-page: https://github.com/leavers/flexexecutor
|
|
5
6
|
Author: leavers
|
|
7
|
+
Author-Email: Leavers <leavers930@gmail.com>
|
|
6
8
|
License: MIT
|
|
7
|
-
Project-URL: homepage, https://github.com/leavers/flexexecutor
|
|
8
|
-
Project-URL: documentation, https://github.com/leavers/flexexecutor/blob/main/README.md
|
|
9
9
|
Classifier: Intended Audience :: Developers
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
11
11
|
Classifier: Operating System :: OS Independent
|
|
@@ -19,31 +19,16 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
19
19
|
Classifier: Topic :: Software Development
|
|
20
20
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
21
|
Classifier: Topic :: Utilities
|
|
22
|
+
Project-URL: Homepage, https://github.com/leavers/flexexecutor
|
|
23
|
+
Project-URL: Documentation, https://github.com/leavers/flexexecutor/blob/main/README.md
|
|
22
24
|
Requires-Python: >=3.8
|
|
23
25
|
Description-Content-Type: text/markdown
|
|
24
|
-
License-File: LICENSE
|
|
25
|
-
Provides-Extra: dev
|
|
26
|
-
Requires-Dist: autoflake; extra == "dev"
|
|
27
|
-
Requires-Dist: bumpver; extra == "dev"
|
|
28
|
-
Requires-Dist: coverage[toml]; extra == "dev"
|
|
29
|
-
Requires-Dist: mypy; extra == "dev"
|
|
30
|
-
Requires-Dist: nox; extra == "dev"
|
|
31
|
-
Requires-Dist: pytest; extra == "dev"
|
|
32
|
-
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
33
|
-
Requires-Dist: pytest-cov; extra == "dev"
|
|
34
|
-
Requires-Dist: pytest-mock; extra == "dev"
|
|
35
|
-
Requires-Dist: pytest-timeout; extra == "dev"
|
|
36
|
-
Requires-Dist: ruff; extra == "dev"
|
|
37
|
-
Provides-Extra: pylsp
|
|
38
|
-
Requires-Dist: python-lsp-server[all]; extra == "pylsp"
|
|
39
|
-
Requires-Dist: pylsp-mypy; extra == "pylsp"
|
|
40
|
-
Requires-Dist: pylsp-rope; extra == "pylsp"
|
|
41
|
-
Requires-Dist: python-lsp-ruff; extra == "pylsp"
|
|
42
|
-
Requires-Dist: python-lsp-black; extra == "pylsp"
|
|
43
26
|
|
|
44
27
|
# Flexexecutor
|
|
45
28
|
|
|
46
|
-
](https://github.com/leavers/flexexecutor/actions)
|
|
30
|
+
[](https://pypi.org/project/flexexecutor/)
|
|
31
|
+
[](https://pypi.org/project/flexexecutor/)
|
|
47
32
|
|
|
48
33
|
Flexexecutor provides executors that can automatically scale the number of workers up
|
|
49
34
|
and down.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Flexexecutor
|
|
2
2
|
|
|
3
|
-
](https://github.com/leavers/flexexecutor/actions)
|
|
4
|
+
[](https://pypi.org/project/flexexecutor/)
|
|
5
|
+
[](https://pypi.org/project/flexexecutor/)
|
|
4
6
|
|
|
5
7
|
Flexexecutor provides executors that can automatically scale the number of workers up
|
|
6
8
|
and down.
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Flexexecutor provides executors that can automatically scale the number of
|
|
3
|
+
workers up and down.
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2020-2024, Leavers.
|
|
6
|
+
License: MIT
|
|
7
|
+
"""
|
|
8
|
+
|
|
1
9
|
import asyncio
|
|
2
10
|
import atexit
|
|
3
11
|
import itertools
|
|
@@ -19,7 +27,7 @@ __all__ = (
|
|
|
19
27
|
"ThreadPoolExecutor",
|
|
20
28
|
)
|
|
21
29
|
|
|
22
|
-
__version__ = "0.0.
|
|
30
|
+
__version__ = "0.0.11"
|
|
23
31
|
|
|
24
32
|
_threads_queues = WeakKeyDictionary() # type: ignore
|
|
25
33
|
_shutdown = False
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "flexexecutor"
|
|
3
|
+
description = "Executors for both async and sync functions and automatically scales the number of workers"
|
|
4
|
+
authors = [
|
|
5
|
+
{ name = "leavers" },
|
|
6
|
+
{ name = "Leavers", email = "leavers930@gmail.com" },
|
|
7
|
+
]
|
|
8
|
+
classifiers = [
|
|
9
|
+
"Intended Audience :: Developers",
|
|
10
|
+
"License :: OSI Approved :: MIT License",
|
|
11
|
+
"Operating System :: OS Independent",
|
|
12
|
+
"Programming Language :: Python",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Programming Language :: Python :: 3.8",
|
|
15
|
+
"Programming Language :: Python :: 3.9",
|
|
16
|
+
"Programming Language :: Python :: 3.10",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Topic :: Software Development",
|
|
20
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
21
|
+
"Topic :: Utilities",
|
|
22
|
+
]
|
|
23
|
+
requires-python = ">=3.8"
|
|
24
|
+
readme = "README.md"
|
|
25
|
+
dependencies = []
|
|
26
|
+
dynamic = []
|
|
27
|
+
version = "0.0.11"
|
|
28
|
+
|
|
29
|
+
[project.license]
|
|
30
|
+
text = "MIT"
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
homepage = "https://github.com/leavers/flexexecutor"
|
|
34
|
+
documentation = "https://github.com/leavers/flexexecutor/blob/main/README.md"
|
|
35
|
+
|
|
36
|
+
[build-system]
|
|
37
|
+
requires = [
|
|
38
|
+
"pdm-backend",
|
|
39
|
+
]
|
|
40
|
+
build-backend = "pdm.backend"
|
|
41
|
+
|
|
42
|
+
[tool.pdm]
|
|
43
|
+
distribution = true
|
|
44
|
+
|
|
45
|
+
[tool.pdm.build]
|
|
46
|
+
includes = [
|
|
47
|
+
"flexexecutor.py",
|
|
48
|
+
]
|
|
49
|
+
excludes = [
|
|
50
|
+
"tests",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[tool.pdm.version]
|
|
54
|
+
source = "file"
|
|
55
|
+
path = "flexexecutor.py"
|
|
56
|
+
|
|
57
|
+
[tool.pdm.dev-dependencies]
|
|
58
|
+
dev = [
|
|
59
|
+
"autoflake>=2.3.1",
|
|
60
|
+
"coverage[toml]>=7.6.1",
|
|
61
|
+
"mypy>=1.11.1",
|
|
62
|
+
"nox>=2024.4.15",
|
|
63
|
+
"pytest>=8.3.2",
|
|
64
|
+
"pytest-asyncio>=0.23.8",
|
|
65
|
+
"pytest-cov>=5.0.0",
|
|
66
|
+
"pytest-mock>=3.14.0",
|
|
67
|
+
"pytest-timeout>=2.3.1",
|
|
68
|
+
"ruoml>=0.11.0",
|
|
69
|
+
"ruff>=0.6.1",
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
[tool.autoflake]
|
|
73
|
+
in-place = true
|
|
74
|
+
recursive = true
|
|
75
|
+
remove-all-unused-imports = true
|
|
76
|
+
ignore-init-module-imports = true
|
|
77
|
+
remove-duplicate-keys = true
|
|
78
|
+
remove-unused-variables = true
|
|
79
|
+
|
|
80
|
+
[tool.coverage.run]
|
|
81
|
+
branch = true
|
|
82
|
+
source = [
|
|
83
|
+
"flexexecutor.py",
|
|
84
|
+
]
|
|
85
|
+
parallel = true
|
|
86
|
+
|
|
87
|
+
[tool.coverage.html]
|
|
88
|
+
directory = "coverage_html_report"
|
|
89
|
+
|
|
90
|
+
[tool.coverage.report]
|
|
91
|
+
show_missing = true
|
|
92
|
+
exclude_lines = [
|
|
93
|
+
"pragma: no cover",
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
[tool.ruff]
|
|
97
|
+
line-length = 88
|
|
98
|
+
|
|
99
|
+
[tool.mypy]
|
|
100
|
+
check_untyped_defs = true
|
|
101
|
+
follow_imports = "error"
|
|
102
|
+
ignore_missing_imports = true
|
|
103
|
+
show_error_codes = true
|
|
104
|
+
warn_unused_configs = true
|
|
105
|
+
|
|
106
|
+
[tool.pytest.ini_options]
|
|
107
|
+
asyncio_mode = "strict"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
## Feature Request
|
|
2
|
-
|
|
3
|
-
**Is your feature request related to a problem? Please describe.**
|
|
4
|
-
A clear and concise description of what the problem is. Ex. I have an issue when [...]
|
|
5
|
-
|
|
6
|
-
**Describe the solution you'd like**
|
|
7
|
-
A clear and concise description of what you want to happen. Add any considered drawbacks.
|
|
8
|
-
|
|
9
|
-
**Describe alternatives you've considered**
|
|
10
|
-
A clear and concise description of any alternative solutions or features you've considered.
|
|
11
|
-
|
|
12
|
-
**Teachability, Documentation, Adoption, Migration Strategy**
|
|
13
|
-
If you can, explain how users will be able to use this and possibly write out a version the docs.
|
|
14
|
-
Maybe a screenshot or design?
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
name: Publish
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
# Run when a new tag has been created
|
|
5
|
-
push:
|
|
6
|
-
tags:
|
|
7
|
-
- "*"
|
|
8
|
-
|
|
9
|
-
# Run when a release has been created
|
|
10
|
-
# release:
|
|
11
|
-
# types: [created]
|
|
12
|
-
|
|
13
|
-
# Allows you to run this workflow manually from the Actions tab
|
|
14
|
-
workflow_dispatch:
|
|
15
|
-
|
|
16
|
-
jobs:
|
|
17
|
-
publish:
|
|
18
|
-
name: "Publish release"
|
|
19
|
-
runs-on: "ubuntu-latest"
|
|
20
|
-
|
|
21
|
-
environment:
|
|
22
|
-
name: deploy
|
|
23
|
-
|
|
24
|
-
steps:
|
|
25
|
-
- uses: actions/checkout@v4
|
|
26
|
-
- uses: actions/setup-python@v5
|
|
27
|
-
with:
|
|
28
|
-
python-version: "3.8"
|
|
29
|
-
- name: "Install dependencies"
|
|
30
|
-
run: |
|
|
31
|
-
python -m pip install --upgrade pip
|
|
32
|
-
python -m pip install nox
|
|
33
|
-
python --version
|
|
34
|
-
pip --version
|
|
35
|
-
nox --version
|
|
36
|
-
- name: "Build wheel and publish to PyPI"
|
|
37
|
-
env:
|
|
38
|
-
TWINE_USERNAME: __token__
|
|
39
|
-
TWINE_PASSWORD: ${{ secrets.pypi_token }}
|
|
40
|
-
run: |
|
|
41
|
-
nox -s publish
|
|
42
|
-
- name: Create Github release
|
|
43
|
-
uses: softprops/action-gh-release@v1
|
|
44
|
-
if: startsWith(github.ref, 'refs/tags/')
|
|
45
|
-
with:
|
|
46
|
-
files: dist/*
|
|
47
|
-
token: ${{ secrets.release_token }}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
name: Test Suite
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- "main"
|
|
7
|
-
pull_request:
|
|
8
|
-
branches:
|
|
9
|
-
- "main"
|
|
10
|
-
|
|
11
|
-
# Allows you to run this workflow manually from the Actions tab
|
|
12
|
-
workflow_dispatch:
|
|
13
|
-
|
|
14
|
-
jobs:
|
|
15
|
-
tests:
|
|
16
|
-
name: "Python ${{ matrix.python-version }} ${{ matrix.os }}"
|
|
17
|
-
runs-on: "${{ matrix.os }}"
|
|
18
|
-
strategy:
|
|
19
|
-
matrix:
|
|
20
|
-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
21
|
-
os: [windows-latest, ubuntu-latest, macos-latest]
|
|
22
|
-
steps:
|
|
23
|
-
- uses: "actions/checkout@v4"
|
|
24
|
-
- uses: "actions/setup-python@v5"
|
|
25
|
-
with:
|
|
26
|
-
python-version: "${{ matrix.python-version }}"
|
|
27
|
-
- name: "Install dependencies"
|
|
28
|
-
run: |
|
|
29
|
-
python -m pip install --upgrade pip
|
|
30
|
-
python -m pip install nox
|
|
31
|
-
python --version
|
|
32
|
-
pip --version
|
|
33
|
-
nox --version
|
|
34
|
-
- name: "Run tests"
|
|
35
|
-
run: |
|
|
36
|
-
nox -s test_for_ci
|
flexexecutor-0.0.9/.gitignore
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
# Byte-compiled / optimized / DLL files
|
|
2
|
-
__pycache__/
|
|
3
|
-
*.py[cod]
|
|
4
|
-
*$py.class
|
|
5
|
-
|
|
6
|
-
# C extensions
|
|
7
|
-
*.so
|
|
8
|
-
|
|
9
|
-
# Distribution / packaging
|
|
10
|
-
.Python
|
|
11
|
-
build/
|
|
12
|
-
develop-eggs/
|
|
13
|
-
dist/
|
|
14
|
-
downloads/
|
|
15
|
-
eggs/
|
|
16
|
-
.eggs/
|
|
17
|
-
lib/
|
|
18
|
-
lib64/
|
|
19
|
-
parts/
|
|
20
|
-
sdist/
|
|
21
|
-
var/
|
|
22
|
-
wheels/
|
|
23
|
-
share/python-wheels/
|
|
24
|
-
*.egg-info/
|
|
25
|
-
.installed.cfg
|
|
26
|
-
*.egg
|
|
27
|
-
MANIFEST
|
|
28
|
-
|
|
29
|
-
# PyInstaller
|
|
30
|
-
# Usually these files are written by a python script from a template
|
|
31
|
-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
-
*.manifest
|
|
33
|
-
*.spec
|
|
34
|
-
|
|
35
|
-
# Installer logs
|
|
36
|
-
pip-log.txt
|
|
37
|
-
pip-delete-this-directory.txt
|
|
38
|
-
|
|
39
|
-
# Unit test / coverage reports
|
|
40
|
-
htmlcov/
|
|
41
|
-
.tox/
|
|
42
|
-
.nox/
|
|
43
|
-
.coverage
|
|
44
|
-
.coverage.*
|
|
45
|
-
.cache
|
|
46
|
-
nosetests.xml
|
|
47
|
-
coverage.xml
|
|
48
|
-
*.cover
|
|
49
|
-
*.py,cover
|
|
50
|
-
.hypothesis/
|
|
51
|
-
.pytest_cache/
|
|
52
|
-
cover/
|
|
53
|
-
|
|
54
|
-
# Translations
|
|
55
|
-
*.mo
|
|
56
|
-
*.pot
|
|
57
|
-
|
|
58
|
-
# Django stuff:
|
|
59
|
-
*.log
|
|
60
|
-
local_settings.py
|
|
61
|
-
db.sqlite3
|
|
62
|
-
db.sqlite3-journal
|
|
63
|
-
|
|
64
|
-
# Flask stuff:
|
|
65
|
-
instance/
|
|
66
|
-
.webassets-cache
|
|
67
|
-
|
|
68
|
-
# Scrapy stuff:
|
|
69
|
-
.scrapy
|
|
70
|
-
|
|
71
|
-
# Sphinx documentation
|
|
72
|
-
docs/_build/
|
|
73
|
-
|
|
74
|
-
# PyBuilder
|
|
75
|
-
.pybuilder/
|
|
76
|
-
target/
|
|
77
|
-
|
|
78
|
-
# Jupyter Notebook
|
|
79
|
-
.ipynb_checkpoints
|
|
80
|
-
|
|
81
|
-
# IPython
|
|
82
|
-
profile_default/
|
|
83
|
-
ipython_config.py
|
|
84
|
-
|
|
85
|
-
# pyenv
|
|
86
|
-
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
-
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
-
.python-version
|
|
89
|
-
|
|
90
|
-
# pipenv
|
|
91
|
-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
-
# install all needed dependencies.
|
|
95
|
-
#Pipfile.lock
|
|
96
|
-
|
|
97
|
-
# poetry
|
|
98
|
-
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
-
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
-
# commonly ignored for libraries.
|
|
101
|
-
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
-
#poetry.lock
|
|
103
|
-
|
|
104
|
-
# pdm
|
|
105
|
-
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
-
#pdm.lock
|
|
107
|
-
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
-
# in version control.
|
|
109
|
-
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
-
.pdm.toml
|
|
111
|
-
.pdm-python
|
|
112
|
-
.pdm-build/
|
|
113
|
-
|
|
114
|
-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
115
|
-
__pypackages__/
|
|
116
|
-
|
|
117
|
-
# Celery stuff
|
|
118
|
-
celerybeat-schedule
|
|
119
|
-
celerybeat.pid
|
|
120
|
-
|
|
121
|
-
# SageMath parsed files
|
|
122
|
-
*.sage.py
|
|
123
|
-
|
|
124
|
-
# Environments
|
|
125
|
-
.env
|
|
126
|
-
.venv
|
|
127
|
-
env/
|
|
128
|
-
venv/
|
|
129
|
-
ENV/
|
|
130
|
-
env.bak/
|
|
131
|
-
venv.bak/
|
|
132
|
-
|
|
133
|
-
# Spyder project settings
|
|
134
|
-
.spyderproject
|
|
135
|
-
.spyproject
|
|
136
|
-
|
|
137
|
-
# Rope project settings
|
|
138
|
-
.ropeproject
|
|
139
|
-
|
|
140
|
-
# mkdocs documentation
|
|
141
|
-
/site
|
|
142
|
-
|
|
143
|
-
# mypy
|
|
144
|
-
.mypy_cache/
|
|
145
|
-
.dmypy.json
|
|
146
|
-
dmypy.json
|
|
147
|
-
|
|
148
|
-
# Pyre type checker
|
|
149
|
-
.pyre/
|
|
150
|
-
|
|
151
|
-
# pytype static type analyzer
|
|
152
|
-
.pytype/
|
|
153
|
-
|
|
154
|
-
# Cython debug symbols
|
|
155
|
-
cython_debug/
|
|
156
|
-
|
|
157
|
-
# PyCharm
|
|
158
|
-
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
159
|
-
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
160
|
-
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
161
|
-
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
162
|
-
.idea/
|
|
163
|
-
|
|
164
|
-
# VSCode
|
|
165
|
-
.vscode
|
|
166
|
-
|
|
167
|
-
# Ruff
|
|
168
|
-
.ruff_cache/
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: flexexecutor
|
|
3
|
-
Version: 0.0.9
|
|
4
|
-
Summary: Executors for both async and sync functions and automatically scales the number of workers
|
|
5
|
-
Author: leavers
|
|
6
|
-
License: MIT
|
|
7
|
-
Project-URL: homepage, https://github.com/leavers/flexexecutor
|
|
8
|
-
Project-URL: documentation, https://github.com/leavers/flexexecutor/blob/main/README.md
|
|
9
|
-
Classifier: Intended Audience :: Developers
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Classifier: Programming Language :: Python
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
-
Classifier: Topic :: Software Development
|
|
20
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
-
Classifier: Topic :: Utilities
|
|
22
|
-
Requires-Python: >=3.8
|
|
23
|
-
Description-Content-Type: text/markdown
|
|
24
|
-
License-File: LICENSE
|
|
25
|
-
Provides-Extra: dev
|
|
26
|
-
Requires-Dist: autoflake; extra == "dev"
|
|
27
|
-
Requires-Dist: bumpver; extra == "dev"
|
|
28
|
-
Requires-Dist: coverage[toml]; extra == "dev"
|
|
29
|
-
Requires-Dist: mypy; extra == "dev"
|
|
30
|
-
Requires-Dist: nox; extra == "dev"
|
|
31
|
-
Requires-Dist: pytest; extra == "dev"
|
|
32
|
-
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
33
|
-
Requires-Dist: pytest-cov; extra == "dev"
|
|
34
|
-
Requires-Dist: pytest-mock; extra == "dev"
|
|
35
|
-
Requires-Dist: pytest-timeout; extra == "dev"
|
|
36
|
-
Requires-Dist: ruff; extra == "dev"
|
|
37
|
-
Provides-Extra: pylsp
|
|
38
|
-
Requires-Dist: python-lsp-server[all]; extra == "pylsp"
|
|
39
|
-
Requires-Dist: pylsp-mypy; extra == "pylsp"
|
|
40
|
-
Requires-Dist: pylsp-rope; extra == "pylsp"
|
|
41
|
-
Requires-Dist: python-lsp-ruff; extra == "pylsp"
|
|
42
|
-
Requires-Dist: python-lsp-black; extra == "pylsp"
|
|
43
|
-
|
|
44
|
-
# Flexexecutor
|
|
45
|
-
|
|
46
|
-

|
|
47
|
-
|
|
48
|
-
Flexexecutor provides executors that can automatically scale the number of workers up
|
|
49
|
-
and down.
|
|
50
|
-
|
|
51
|
-
## Overview
|
|
52
|
-
|
|
53
|
-
Flexexecutor implements several subclasses of `concurrent.futures.Executor`.
|
|
54
|
-
Like the built-in `ThreadPoolExecutor` and `ProcessPoolExecutor`,
|
|
55
|
-
they create multiple workers to execute tasks concurrently.
|
|
56
|
-
Additionally, it can shut down idle workers to save resources. These subclasses are:
|
|
57
|
-
|
|
58
|
-
- `ThreadPoolExecutor` - thread concurrency, same name as the built-in class and can
|
|
59
|
-
be a in-place replacement.
|
|
60
|
-
- `AsyncPoolExecutor` - coroutine concurrency. Note that in flexexecutor's
|
|
61
|
-
implementation, all coroutines are executed in a dedicated worker thread.
|
|
62
|
-
- `ProcessPoolExecutor` - flexexecutor directly imports the built-in implementation as it
|
|
63
|
-
already has scaling capabilities.
|
|
64
|
-
|
|
65
|
-
## Features
|
|
66
|
-
|
|
67
|
-
- Supports various concurrency modes: threads, processes and coroutines.
|
|
68
|
-
- Automatically shut down idle workers to save resources.
|
|
69
|
-
- Single file design, keeps the code clean and easy for hackers to directly take away
|
|
70
|
-
and add more features.
|
|
71
|
-
|
|
72
|
-
## Installation
|
|
73
|
-
|
|
74
|
-
Flexexecutor is available on [PyPI](https://pypi.org/project/flexexecutor/):
|
|
75
|
-
|
|
76
|
-
```shell
|
|
77
|
-
pip install flexexecutor
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Usage
|
|
81
|
-
|
|
82
|
-
### ThreadPoolExecutor
|
|
83
|
-
|
|
84
|
-
```python
|
|
85
|
-
from flexexecutor import ThreadPoolExecutor
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
def task(i):
|
|
89
|
-
import time
|
|
90
|
-
|
|
91
|
-
print(f"task {i} started")
|
|
92
|
-
time.sleep(1)
|
|
93
|
-
|
|
94
|
-
if __name__ == "__main__":
|
|
95
|
-
with ThreadPoolExecutor(
|
|
96
|
-
# 1024 is the default value of max_workers, since workers are closed if they are
|
|
97
|
-
# idle for some time, you can set it to a big value to get better short-term
|
|
98
|
-
# performance.
|
|
99
|
-
max_workers=1024,
|
|
100
|
-
# Timeout for idle workers.
|
|
101
|
-
idle_timeout=60.0,
|
|
102
|
-
# These parameters are given for compatibility with the built-in
|
|
103
|
-
# `ThreadPoolExecutor`, I don't use them very often, do you?
|
|
104
|
-
thread_name_prefix="Task",
|
|
105
|
-
initializer=None,
|
|
106
|
-
initargs=(),
|
|
107
|
-
) as executor:
|
|
108
|
-
for i in range(1024):
|
|
109
|
-
executor.submit(task, i)
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### AsyncPoolExecutor
|
|
113
|
-
|
|
114
|
-
```python
|
|
115
|
-
from flexexecutor import AsyncPoolExecutor
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
async def task(i):
|
|
119
|
-
import asyncio
|
|
120
|
-
|
|
121
|
-
print(f"task {i} started")
|
|
122
|
-
await asyncio.sleep(1)
|
|
123
|
-
|
|
124
|
-
if __name__ == "__main__":
|
|
125
|
-
# AsyncPoolExecutor behaves just like ThreadPoolExecutor except it only accepts
|
|
126
|
-
# coroutine functions.
|
|
127
|
-
with AsyncPoolExecutor(
|
|
128
|
-
# Default value of max_workers is huge, if you don't like it, set it smaller.
|
|
129
|
-
max_workers=1024,
|
|
130
|
-
# Idle timeout for the working thread.
|
|
131
|
-
idle_timeout=60.0,
|
|
132
|
-
# These parameters are given for compatibility with the built-in
|
|
133
|
-
# `ThreadPoolExecutor`, I don't use them very often, do you?
|
|
134
|
-
thread_name_prefix="Task",
|
|
135
|
-
initializer=None,
|
|
136
|
-
initargs=(),
|
|
137
|
-
) as executor:
|
|
138
|
-
for i in range(1024):
|
|
139
|
-
executor.submit(task, i)
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### ProcessPoolExecutor
|
|
143
|
-
|
|
144
|
-
`ProcessPoolExecutor` in flexexecutor is just the same as the built-in
|
|
145
|
-
`concurrent.futures.ProcessPoolExecutor`, we just import it directly for convenience.
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
.gitignore
|
|
2
|
-
LICENSE
|
|
3
|
-
README.md
|
|
4
|
-
flexexecutor.py
|
|
5
|
-
noxfile.py
|
|
6
|
-
pyproject.toml
|
|
7
|
-
.github/ISSUE_TEMPLATE/bug_report.md
|
|
8
|
-
.github/ISSUE_TEMPLATE/feature_request.md
|
|
9
|
-
.github/workflows/publish.yml
|
|
10
|
-
.github/workflows/test-suite.yml
|
|
11
|
-
flexexecutor.egg-info/PKG-INFO
|
|
12
|
-
flexexecutor.egg-info/SOURCES.txt
|
|
13
|
-
flexexecutor.egg-info/dependency_links.txt
|
|
14
|
-
flexexecutor.egg-info/requires.txt
|
|
15
|
-
flexexecutor.egg-info/top_level.txt
|
|
16
|
-
tests/__init__.py
|
|
17
|
-
tests/conftest.py
|
|
18
|
-
tests/test_async.py
|
|
19
|
-
tests/test_thread.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
[dev]
|
|
3
|
-
autoflake
|
|
4
|
-
bumpver
|
|
5
|
-
coverage[toml]
|
|
6
|
-
mypy
|
|
7
|
-
nox
|
|
8
|
-
pytest
|
|
9
|
-
pytest-asyncio
|
|
10
|
-
pytest-cov
|
|
11
|
-
pytest-mock
|
|
12
|
-
pytest-timeout
|
|
13
|
-
ruff
|
|
14
|
-
|
|
15
|
-
[pylsp]
|
|
16
|
-
python-lsp-server[all]
|
|
17
|
-
pylsp-mypy
|
|
18
|
-
pylsp-rope
|
|
19
|
-
python-lsp-ruff
|
|
20
|
-
python-lsp-black
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
flexexecutor
|