├── .gitignore ├── .pre-commit-config.yaml ├── LICENSE ├── README.md ├── poetry.lock ├── pyproject.toml ├── single_consumer_queue ├── __init__.py ├── py.typed └── queue.py └── tests ├── __init__.py └── test_single_consumer_queue.py /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LukasKrocek/single-consumer-queue-python/3dce29d8af57611c3452e841e8e96d5b9f12eaff/.gitignore -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # See https://pre-commit.com for more information 2 | # See https://pre-commit.com/hooks.html for more hooks 3 | default_language_version: 4 | python: python3.10 5 | repos: 6 | - repo: https://github.com/pre-commit/pre-commit-hooks 7 | rev: v3.1.0 8 | hooks: 9 | - id: mixed-line-ending 10 | - id: check-added-large-files 11 | - id: end-of-file-fixer 12 | - id: trailing-whitespace 13 | - id: check-ast 14 | - repo: https://github.com/psf/black 15 | rev: 23.1.0 16 | hooks: 17 | - id: black 18 | args: 19 | - --line-length=120 20 | - --target-version=py310 21 | - repo: https://github.com/charliermarsh/ruff-pre-commit 22 | rev: 'v0.0.254' 23 | hooks: 24 | - id: ruff 25 | args: 26 | - --fix 27 | - --show-fixes 28 | - --exit-non-zero-on-fix 29 | - --line-length=120 30 | - --verbose 31 | - --select=A,B,C,E,F,I,M,N,Q,R,T,U,W 32 | - --ignore=A003,B023,B024,B008 33 | - repo: local 34 | hooks: 35 | - id: mypy 36 | name: mypy 37 | entry: mypy 38 | language: system 39 | types: [python] 40 | pass_filenames: false 41 | args: 42 | [ 43 | "--strict", "--show-error-codes", "single_consumer_queue", "tests" 44 | ] 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Lukas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Single Consumer Queue 2 | Single Consumer Queue is a Python library that provides an alternative to the standard asyncio.Queue for single consumer scenarios. It consists of two classes: SingleConsumerQueue and SingleConsumerPriorityQueue. Both classes implement the AbstractSingleConsumerQueue abstract base class, which provides the basic functionality of a single consumer queue. 3 | 4 | ## Why Single Consumer Queue? 5 | In some scenarios, the standard asyncio.Queue can be slower than necessary. This is because asyncio.Queue is designed to be used with multiple consumers, which means that it has additional overhead to handle multiple concurrent accesses. If you only have one consumer, you can use SingleConsumerQueue or SingleConsumerPriorityQueue to reduce this overhead and improve performance. 6 | 7 | ## How to use Single Consumer Queue 8 | Installation 9 | You can install Single Consumer Queue using pip: 10 | 11 | ```pip install single-consumer-queue``` 12 | 13 | ## Usage 14 | Here's an example of how to use SingleConsumerQueue: 15 | 16 | ``` 17 | async def consumer(queue: SingleConsumerQueue | SingleConsumerPriorityQueue): 18 | async for item in queue.start_consuming(): 19 | print(item) 20 | ``` 21 | 22 | SingleConsumerQueue raises exception if you try to add multiple consumers: 23 | 24 | ``` 25 | async def consumer(queue: SingleConsumerQueue | SingleConsumerPriorityQueue): 26 | async for item in queue.start_consuming(): 27 | print(item) 28 | 29 | queue = SingleConsumerQueue() 30 | asyncio.create_task(consumer(queue)) 31 | await asyncio sleep(0.1) 32 | await queue.get() # raises runtime error 33 | ``` 34 | 35 | Lock is checked and acquired when consumer starts and every time that get is awaited. 36 | 37 | Get has considerate overhead because it has to use lock every time, so it is recommended to use `start_consuming` generator when you want to consume items in the loop. 38 | -------------------------------------------------------------------------------- /poetry.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "cfgv" 3 | version = "3.3.1" 4 | description = "Validate configuration and produce human readable error messages." 5 | category = "dev" 6 | optional = false 7 | python-versions = ">=3.6.1" 8 | 9 | [[package]] 10 | name = "colorama" 11 | version = "0.4.6" 12 | description = "Cross-platform colored terminal text." 13 | category = "dev" 14 | optional = false 15 | python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" 16 | 17 | [[package]] 18 | name = "coverage" 19 | version = "7.2.3" 20 | description = "Code coverage measurement for Python" 21 | category = "dev" 22 | optional = false 23 | python-versions = ">=3.7" 24 | 25 | [package.dependencies] 26 | tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.11.0a6\" and extra == \"toml\""} 27 | 28 | [package.extras] 29 | toml = ["tomli"] 30 | 31 | [[package]] 32 | name = "distlib" 33 | version = "0.3.6" 34 | description = "Distribution utilities" 35 | category = "dev" 36 | optional = false 37 | python-versions = "*" 38 | 39 | [[package]] 40 | name = "exceptiongroup" 41 | version = "1.1.1" 42 | description = "Backport of PEP 654 (exception groups)" 43 | category = "dev" 44 | optional = false 45 | python-versions = ">=3.7" 46 | 47 | [package.extras] 48 | test = ["pytest (>=6)"] 49 | 50 | [[package]] 51 | name = "filelock" 52 | version = "3.12.0" 53 | description = "A platform independent file lock." 54 | category = "dev" 55 | optional = false 56 | python-versions = ">=3.7" 57 | 58 | [package.extras] 59 | docs = ["furo (>=2023.3.27)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] 60 | testing = ["covdefaults (>=2.3)", "coverage (>=7.2.3)", "diff-cover (>=7.5)", "pytest (>=7.3.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)", "pytest-timeout (>=2.1)"] 61 | 62 | [[package]] 63 | name = "identify" 64 | version = "2.5.23" 65 | description = "File identification library for Python" 66 | category = "dev" 67 | optional = false 68 | python-versions = ">=3.7" 69 | 70 | [package.extras] 71 | license = ["ukkonen"] 72 | 73 | [[package]] 74 | name = "iniconfig" 75 | version = "2.0.0" 76 | description = "brain-dead simple config-ini parsing" 77 | category = "dev" 78 | optional = false 79 | python-versions = ">=3.7" 80 | 81 | [[package]] 82 | name = "mypy" 83 | version = "1.2.0" 84 | description = "Optional static typing for Python" 85 | category = "dev" 86 | optional = false 87 | python-versions = ">=3.7" 88 | 89 | [package.dependencies] 90 | mypy-extensions = ">=1.0.0" 91 | tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} 92 | typing-extensions = ">=3.10" 93 | 94 | [package.extras] 95 | dmypy = ["psutil (>=4.0)"] 96 | install-types = ["pip"] 97 | python2 = ["typed-ast (>=1.4.0,<2)"] 98 | reports = ["lxml"] 99 | 100 | [[package]] 101 | name = "mypy-extensions" 102 | version = "1.0.0" 103 | description = "Type system extensions for programs checked with the mypy type checker." 104 | category = "dev" 105 | optional = false 106 | python-versions = ">=3.5" 107 | 108 | [[package]] 109 | name = "nodeenv" 110 | version = "1.7.0" 111 | description = "Node.js virtual environment builder" 112 | category = "dev" 113 | optional = false 114 | python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" 115 | 116 | [package.dependencies] 117 | setuptools = "*" 118 | 119 | [[package]] 120 | name = "packaging" 121 | version = "23.1" 122 | description = "Core utilities for Python packages" 123 | category = "dev" 124 | optional = false 125 | python-versions = ">=3.7" 126 | 127 | [[package]] 128 | name = "platformdirs" 129 | version = "3.4.0" 130 | description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." 131 | category = "dev" 132 | optional = false 133 | python-versions = ">=3.7" 134 | 135 | [package.extras] 136 | docs = ["furo (>=2023.3.27)", "proselint (>=0.13)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] 137 | test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.3.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] 138 | 139 | [[package]] 140 | name = "pluggy" 141 | version = "1.0.0" 142 | description = "plugin and hook calling mechanisms for python" 143 | category = "dev" 144 | optional = false 145 | python-versions = ">=3.6" 146 | 147 | [package.extras] 148 | dev = ["pre-commit", "tox"] 149 | testing = ["pytest", "pytest-benchmark"] 150 | 151 | [[package]] 152 | name = "pre-commit" 153 | version = "3.2.2" 154 | description = "A framework for managing and maintaining multi-language pre-commit hooks." 155 | category = "dev" 156 | optional = false 157 | python-versions = ">=3.8" 158 | 159 | [package.dependencies] 160 | cfgv = ">=2.0.0" 161 | identify = ">=1.0.0" 162 | nodeenv = ">=0.11.1" 163 | pyyaml = ">=5.1" 164 | virtualenv = ">=20.10.0" 165 | 166 | [[package]] 167 | name = "pytest" 168 | version = "7.3.1" 169 | description = "pytest: simple powerful testing with Python" 170 | category = "dev" 171 | optional = false 172 | python-versions = ">=3.7" 173 | 174 | [package.dependencies] 175 | colorama = {version = "*", markers = "sys_platform == \"win32\""} 176 | exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} 177 | iniconfig = "*" 178 | packaging = "*" 179 | pluggy = ">=0.12,<2.0" 180 | tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} 181 | 182 | [package.extras] 183 | testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] 184 | 185 | [[package]] 186 | name = "pytest-asyncio" 187 | version = "0.21.0" 188 | description = "Pytest support for asyncio" 189 | category = "dev" 190 | optional = false 191 | python-versions = ">=3.7" 192 | 193 | [package.dependencies] 194 | pytest = ">=7.0.0" 195 | 196 | [package.extras] 197 | docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] 198 | testing = ["coverage (>=6.2)", "flaky (>=3.5.0)", "hypothesis (>=5.7.1)", "mypy (>=0.931)", "pytest-trio (>=0.7.0)"] 199 | 200 | [[package]] 201 | name = "pytest-cov" 202 | version = "4.0.0" 203 | description = "Pytest plugin for measuring coverage." 204 | category = "dev" 205 | optional = false 206 | python-versions = ">=3.6" 207 | 208 | [package.dependencies] 209 | coverage = {version = ">=5.2.1", extras = ["toml"]} 210 | pytest = ">=4.6" 211 | 212 | [package.extras] 213 | testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] 214 | 215 | [[package]] 216 | name = "pyyaml" 217 | version = "6.0" 218 | description = "YAML parser and emitter for Python" 219 | category = "dev" 220 | optional = false 221 | python-versions = ">=3.6" 222 | 223 | [[package]] 224 | name = "setuptools" 225 | version = "67.7.2" 226 | description = "Easily download, build, install, upgrade, and uninstall Python packages" 227 | category = "dev" 228 | optional = false 229 | python-versions = ">=3.7" 230 | 231 | [package.extras] 232 | docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"] 233 | testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8 (<5)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] 234 | testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] 235 | 236 | [[package]] 237 | name = "tomli" 238 | version = "2.0.1" 239 | description = "A lil' TOML parser" 240 | category = "dev" 241 | optional = false 242 | python-versions = ">=3.7" 243 | 244 | [[package]] 245 | name = "typing-extensions" 246 | version = "4.5.0" 247 | description = "Backported and Experimental Type Hints for Python 3.7+" 248 | category = "dev" 249 | optional = false 250 | python-versions = ">=3.7" 251 | 252 | [[package]] 253 | name = "virtualenv" 254 | version = "20.22.0" 255 | description = "Virtual Python Environment builder" 256 | category = "dev" 257 | optional = false 258 | python-versions = ">=3.7" 259 | 260 | [package.dependencies] 261 | distlib = ">=0.3.6,<1" 262 | filelock = ">=3.11,<4" 263 | platformdirs = ">=3.2,<4" 264 | 265 | [package.extras] 266 | docs = ["furo (>=2023.3.27)", "proselint (>=0.13)", "sphinx (>=6.1.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=22.12)"] 267 | test = ["covdefaults (>=2.3)", "coverage (>=7.2.3)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.3.1)", "pytest-env (>=0.8.1)", "pytest-freezegun (>=0.4.2)", "pytest-mock (>=3.10)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)"] 268 | 269 | [metadata] 270 | lock-version = "1.1" 271 | python-versions = "^3.10" 272 | content-hash = "22339909cb398d65e3c38be713cf22a9d9de4f9d937e5b6e40ddf01016b53ee8" 273 | 274 | [metadata.files] 275 | cfgv = [ 276 | {file = "cfgv-3.3.1-py2.py3-none-any.whl", hash = "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426"}, 277 | {file = "cfgv-3.3.1.tar.gz", hash = "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736"}, 278 | ] 279 | colorama = [ 280 | {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, 281 | {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, 282 | ] 283 | coverage = [ 284 | {file = "coverage-7.2.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e58c0d41d336569d63d1b113bd573db8363bc4146f39444125b7f8060e4e04f5"}, 285 | {file = "coverage-7.2.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:344e714bd0fe921fc72d97404ebbdbf9127bac0ca1ff66d7b79efc143cf7c0c4"}, 286 | {file = "coverage-7.2.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:974bc90d6f6c1e59ceb1516ab00cf1cdfbb2e555795d49fa9571d611f449bcb2"}, 287 | {file = "coverage-7.2.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0743b0035d4b0e32bc1df5de70fba3059662ace5b9a2a86a9f894cfe66569013"}, 288 | {file = "coverage-7.2.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5d0391fb4cfc171ce40437f67eb050a340fdbd0f9f49d6353a387f1b7f9dd4fa"}, 289 | {file = "coverage-7.2.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4a42e1eff0ca9a7cb7dc9ecda41dfc7cbc17cb1d02117214be0561bd1134772b"}, 290 | {file = "coverage-7.2.3-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:be19931a8dcbe6ab464f3339966856996b12a00f9fe53f346ab3be872d03e257"}, 291 | {file = "coverage-7.2.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:72fcae5bcac3333a4cf3b8f34eec99cea1187acd55af723bcbd559adfdcb5535"}, 292 | {file = "coverage-7.2.3-cp310-cp310-win32.whl", hash = "sha256:aeae2aa38395b18106e552833f2a50c27ea0000122bde421c31d11ed7e6f9c91"}, 293 | {file = "coverage-7.2.3-cp310-cp310-win_amd64.whl", hash = "sha256:83957d349838a636e768251c7e9979e899a569794b44c3728eaebd11d848e58e"}, 294 | {file = "coverage-7.2.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:dfd393094cd82ceb9b40df4c77976015a314b267d498268a076e940fe7be6b79"}, 295 | {file = "coverage-7.2.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:182eb9ac3f2b4874a1f41b78b87db20b66da6b9cdc32737fbbf4fea0c35b23fc"}, 296 | {file = "coverage-7.2.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1bb1e77a9a311346294621be905ea8a2c30d3ad371fc15bb72e98bfcfae532df"}, 297 | {file = "coverage-7.2.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ca0f34363e2634deffd390a0fef1aa99168ae9ed2af01af4a1f5865e362f8623"}, 298 | {file = "coverage-7.2.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:55416d7385774285b6e2a5feca0af9652f7f444a4fa3d29d8ab052fafef9d00d"}, 299 | {file = "coverage-7.2.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:06ddd9c0249a0546997fdda5a30fbcb40f23926df0a874a60a8a185bc3a87d93"}, 300 | {file = "coverage-7.2.3-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:fff5aaa6becf2c6a1699ae6a39e2e6fb0672c2d42eca8eb0cafa91cf2e9bd312"}, 301 | {file = "coverage-7.2.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:ea53151d87c52e98133eb8ac78f1206498c015849662ca8dc246255265d9c3c4"}, 302 | {file = "coverage-7.2.3-cp311-cp311-win32.whl", hash = "sha256:8f6c930fd70d91ddee53194e93029e3ef2aabe26725aa3c2753df057e296b925"}, 303 | {file = "coverage-7.2.3-cp311-cp311-win_amd64.whl", hash = "sha256:fa546d66639d69aa967bf08156eb8c9d0cd6f6de84be9e8c9819f52ad499c910"}, 304 | {file = "coverage-7.2.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b2317d5ed777bf5a033e83d4f1389fd4ef045763141d8f10eb09a7035cee774c"}, 305 | {file = "coverage-7.2.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:be9824c1c874b73b96288c6d3de793bf7f3a597770205068c6163ea1f326e8b9"}, 306 | {file = "coverage-7.2.3-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2c3b2803e730dc2797a017335827e9da6da0e84c745ce0f552e66400abdfb9a1"}, 307 | {file = "coverage-7.2.3-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f69770f5ca1994cb32c38965e95f57504d3aea96b6c024624fdd5bb1aa494a1"}, 308 | {file = "coverage-7.2.3-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:1127b16220f7bfb3f1049ed4a62d26d81970a723544e8252db0efde853268e21"}, 309 | {file = "coverage-7.2.3-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:aa784405f0c640940595fa0f14064d8e84aff0b0f762fa18393e2760a2cf5841"}, 310 | {file = "coverage-7.2.3-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:3146b8e16fa60427e03884301bf8209221f5761ac754ee6b267642a2fd354c48"}, 311 | {file = "coverage-7.2.3-cp37-cp37m-win32.whl", hash = "sha256:1fd78b911aea9cec3b7e1e2622c8018d51c0d2bbcf8faaf53c2497eb114911c1"}, 312 | {file = "coverage-7.2.3-cp37-cp37m-win_amd64.whl", hash = "sha256:0f3736a5d34e091b0a611964c6262fd68ca4363df56185902528f0b75dbb9c1f"}, 313 | {file = "coverage-7.2.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:981b4df72c93e3bc04478153df516d385317628bd9c10be699c93c26ddcca8ab"}, 314 | {file = "coverage-7.2.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c0045f8f23a5fb30b2eb3b8a83664d8dc4fb58faddf8155d7109166adb9f2040"}, 315 | {file = "coverage-7.2.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f760073fcf8f3d6933178d67754f4f2d4e924e321f4bb0dcef0424ca0215eba1"}, 316 | {file = "coverage-7.2.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c86bd45d1659b1ae3d0ba1909326b03598affbc9ed71520e0ff8c31a993ad911"}, 317 | {file = "coverage-7.2.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:172db976ae6327ed4728e2507daf8a4de73c7cc89796483e0a9198fd2e47b462"}, 318 | {file = "coverage-7.2.3-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:d2a3a6146fe9319926e1d477842ca2a63fe99af5ae690b1f5c11e6af074a6b5c"}, 319 | {file = "coverage-7.2.3-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:f649dd53833b495c3ebd04d6eec58479454a1784987af8afb77540d6c1767abd"}, 320 | {file = "coverage-7.2.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:7c4ed4e9f3b123aa403ab424430b426a1992e6f4c8fd3cb56ea520446e04d152"}, 321 | {file = "coverage-7.2.3-cp38-cp38-win32.whl", hash = "sha256:eb0edc3ce9760d2f21637766c3aa04822030e7451981ce569a1b3456b7053f22"}, 322 | {file = "coverage-7.2.3-cp38-cp38-win_amd64.whl", hash = "sha256:63cdeaac4ae85a179a8d6bc09b77b564c096250d759eed343a89d91bce8b6367"}, 323 | {file = "coverage-7.2.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:20d1a2a76bb4eb00e4d36b9699f9b7aba93271c9c29220ad4c6a9581a0320235"}, 324 | {file = "coverage-7.2.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4ea748802cc0de4de92ef8244dd84ffd793bd2e7be784cd8394d557a3c751e21"}, 325 | {file = "coverage-7.2.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:21b154aba06df42e4b96fc915512ab39595105f6c483991287021ed95776d934"}, 326 | {file = "coverage-7.2.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fd214917cabdd6f673a29d708574e9fbdb892cb77eb426d0eae3490d95ca7859"}, 327 | {file = "coverage-7.2.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2c2e58e45fe53fab81f85474e5d4d226eeab0f27b45aa062856c89389da2f0d9"}, 328 | {file = "coverage-7.2.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:87ecc7c9a1a9f912e306997ffee020297ccb5ea388421fe62a2a02747e4d5539"}, 329 | {file = "coverage-7.2.3-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:387065e420aed3c71b61af7e82c7b6bc1c592f7e3c7a66e9f78dd178699da4fe"}, 330 | {file = "coverage-7.2.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ea3f5bc91d7d457da7d48c7a732beaf79d0c8131df3ab278e6bba6297e23c6c4"}, 331 | {file = "coverage-7.2.3-cp39-cp39-win32.whl", hash = "sha256:ae7863a1d8db6a014b6f2ff9c1582ab1aad55a6d25bac19710a8df68921b6e30"}, 332 | {file = "coverage-7.2.3-cp39-cp39-win_amd64.whl", hash = "sha256:3f04becd4fcda03c0160d0da9c8f0c246bc78f2f7af0feea1ec0930e7c93fa4a"}, 333 | {file = "coverage-7.2.3-pp37.pp38.pp39-none-any.whl", hash = "sha256:965ee3e782c7892befc25575fa171b521d33798132692df428a09efacaffe8d0"}, 334 | {file = "coverage-7.2.3.tar.gz", hash = "sha256:d298c2815fa4891edd9abe5ad6e6cb4207104c7dd9fd13aea3fdebf6f9b91259"}, 335 | ] 336 | distlib = [ 337 | {file = "distlib-0.3.6-py2.py3-none-any.whl", hash = "sha256:f35c4b692542ca110de7ef0bea44d73981caeb34ca0b9b6b2e6d7790dda8f80e"}, 338 | {file = "distlib-0.3.6.tar.gz", hash = "sha256:14bad2d9b04d3a36127ac97f30b12a19268f211063d8f8ee4f47108896e11b46"}, 339 | ] 340 | exceptiongroup = [ 341 | {file = "exceptiongroup-1.1.1-py3-none-any.whl", hash = "sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e"}, 342 | {file = "exceptiongroup-1.1.1.tar.gz", hash = "sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785"}, 343 | ] 344 | filelock = [ 345 | {file = "filelock-3.12.0-py3-none-any.whl", hash = "sha256:ad98852315c2ab702aeb628412cbf7e95b7ce8c3bf9565670b4eaecf1db370a9"}, 346 | {file = "filelock-3.12.0.tar.gz", hash = "sha256:fc03ae43288c013d2ea83c8597001b1129db351aad9c57fe2409327916b8e718"}, 347 | ] 348 | identify = [ 349 | {file = "identify-2.5.23-py2.py3-none-any.whl", hash = "sha256:17d9351c028a781456965e781ed2a435755cac655df1ebd930f7186b54399312"}, 350 | {file = "identify-2.5.23.tar.gz", hash = "sha256:50b01b9d5f73c6b53e5fa2caf9f543d3e657a9d0bbdeb203ebb8d45960ba7433"}, 351 | ] 352 | iniconfig = [ 353 | {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, 354 | {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, 355 | ] 356 | mypy = [ 357 | {file = "mypy-1.2.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:701189408b460a2ff42b984e6bd45c3f41f0ac9f5f58b8873bbedc511900086d"}, 358 | {file = "mypy-1.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fe91be1c51c90e2afe6827601ca14353bbf3953f343c2129fa1e247d55fd95ba"}, 359 | {file = "mypy-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d26b513225ffd3eacece727f4387bdce6469192ef029ca9dd469940158bc89e"}, 360 | {file = "mypy-1.2.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:3a2d219775a120581a0ae8ca392b31f238d452729adbcb6892fa89688cb8306a"}, 361 | {file = "mypy-1.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:2e93a8a553e0394b26c4ca683923b85a69f7ccdc0139e6acd1354cc884fe0128"}, 362 | {file = "mypy-1.2.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3efde4af6f2d3ccf58ae825495dbb8d74abd6d176ee686ce2ab19bd025273f41"}, 363 | {file = "mypy-1.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:695c45cea7e8abb6f088a34a6034b1d273122e5530aeebb9c09626cea6dca4cb"}, 364 | {file = "mypy-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d0e9464a0af6715852267bf29c9553e4555b61f5904a4fc538547a4d67617937"}, 365 | {file = "mypy-1.2.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8293a216e902ac12779eb7a08f2bc39ec6c878d7c6025aa59464e0c4c16f7eb9"}, 366 | {file = "mypy-1.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:f46af8d162f3d470d8ffc997aaf7a269996d205f9d746124a179d3abe05ac602"}, 367 | {file = "mypy-1.2.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:031fc69c9a7e12bcc5660b74122ed84b3f1c505e762cc4296884096c6d8ee140"}, 368 | {file = "mypy-1.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:390bc685ec209ada4e9d35068ac6988c60160b2b703072d2850457b62499e336"}, 369 | {file = "mypy-1.2.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:4b41412df69ec06ab141808d12e0bf2823717b1c363bd77b4c0820feaa37249e"}, 370 | {file = "mypy-1.2.0-cp37-cp37m-win_amd64.whl", hash = "sha256:4e4a682b3f2489d218751981639cffc4e281d548f9d517addfd5a2917ac78119"}, 371 | {file = "mypy-1.2.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a197ad3a774f8e74f21e428f0de7f60ad26a8d23437b69638aac2764d1e06a6a"}, 372 | {file = "mypy-1.2.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c9a084bce1061e55cdc0493a2ad890375af359c766b8ac311ac8120d3a472950"}, 373 | {file = "mypy-1.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eaeaa0888b7f3ccb7bcd40b50497ca30923dba14f385bde4af78fac713d6d6f6"}, 374 | {file = "mypy-1.2.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:bea55fc25b96c53affab852ad94bf111a3083bc1d8b0c76a61dd101d8a388cf5"}, 375 | {file = "mypy-1.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:4c8d8c6b80aa4a1689f2a179d31d86ae1367ea4a12855cc13aa3ba24bb36b2d8"}, 376 | {file = "mypy-1.2.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:70894c5345bea98321a2fe84df35f43ee7bb0feec117a71420c60459fc3e1eed"}, 377 | {file = "mypy-1.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4a99fe1768925e4a139aace8f3fb66db3576ee1c30b9c0f70f744ead7e329c9f"}, 378 | {file = "mypy-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:023fe9e618182ca6317ae89833ba422c411469156b690fde6a315ad10695a521"}, 379 | {file = "mypy-1.2.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4d19f1a239d59f10fdc31263d48b7937c585810288376671eaf75380b074f238"}, 380 | {file = "mypy-1.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:2de7babe398cb7a85ac7f1fd5c42f396c215ab3eff731b4d761d68d0f6a80f48"}, 381 | {file = "mypy-1.2.0-py3-none-any.whl", hash = "sha256:d8e9187bfcd5ffedbe87403195e1fc340189a68463903c39e2b63307c9fa0394"}, 382 | {file = "mypy-1.2.0.tar.gz", hash = "sha256:f70a40410d774ae23fcb4afbbeca652905a04de7948eaf0b1789c8d1426b72d1"}, 383 | ] 384 | mypy-extensions = [ 385 | {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, 386 | {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, 387 | ] 388 | nodeenv = [ 389 | {file = "nodeenv-1.7.0-py2.py3-none-any.whl", hash = "sha256:27083a7b96a25f2f5e1d8cb4b6317ee8aeda3bdd121394e5ac54e498028a042e"}, 390 | {file = "nodeenv-1.7.0.tar.gz", hash = "sha256:e0e7f7dfb85fc5394c6fe1e8fa98131a2473e04311a45afb6508f7cf1836fa2b"}, 391 | ] 392 | packaging = [ 393 | {file = "packaging-23.1-py3-none-any.whl", hash = "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61"}, 394 | {file = "packaging-23.1.tar.gz", hash = "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"}, 395 | ] 396 | platformdirs = [ 397 | {file = "platformdirs-3.4.0-py3-none-any.whl", hash = "sha256:01437886022decaf285d8972f9526397bfae2ac55480ed372ed6d9eca048870a"}, 398 | {file = "platformdirs-3.4.0.tar.gz", hash = "sha256:a5e1536e5ea4b1c238a1364da17ff2993d5bd28e15600c2c8224008aff6bbcad"}, 399 | ] 400 | pluggy = [ 401 | {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, 402 | {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, 403 | ] 404 | pre-commit = [ 405 | {file = "pre_commit-3.2.2-py2.py3-none-any.whl", hash = "sha256:0b4210aea813fe81144e87c5a291f09ea66f199f367fa1df41b55e1d26e1e2b4"}, 406 | {file = "pre_commit-3.2.2.tar.gz", hash = "sha256:5b808fcbda4afbccf6d6633a56663fed35b6c2bc08096fd3d47ce197ac351d9d"}, 407 | ] 408 | pytest = [ 409 | {file = "pytest-7.3.1-py3-none-any.whl", hash = "sha256:3799fa815351fea3a5e96ac7e503a96fa51cc9942c3753cda7651b93c1cfa362"}, 410 | {file = "pytest-7.3.1.tar.gz", hash = "sha256:434afafd78b1d78ed0addf160ad2b77a30d35d4bdf8af234fe621919d9ed15e3"}, 411 | ] 412 | pytest-asyncio = [ 413 | {file = "pytest-asyncio-0.21.0.tar.gz", hash = "sha256:2b38a496aef56f56b0e87557ec313e11e1ab9276fc3863f6a7be0f1d0e415e1b"}, 414 | {file = "pytest_asyncio-0.21.0-py3-none-any.whl", hash = "sha256:f2b3366b7cd501a4056858bd39349d5af19742aed2d81660b7998b6341c7eb9c"}, 415 | ] 416 | pytest-cov = [ 417 | {file = "pytest-cov-4.0.0.tar.gz", hash = "sha256:996b79efde6433cdbd0088872dbc5fb3ed7fe1578b68cdbba634f14bb8dd0470"}, 418 | {file = "pytest_cov-4.0.0-py3-none-any.whl", hash = "sha256:2feb1b751d66a8bd934e5edfa2e961d11309dc37b73b0eabe73b5945fee20f6b"}, 419 | ] 420 | pyyaml = [ 421 | {file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"}, 422 | {file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"}, 423 | {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc"}, 424 | {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b"}, 425 | {file = "PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"}, 426 | {file = "PyYAML-6.0-cp310-cp310-win32.whl", hash = "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513"}, 427 | {file = "PyYAML-6.0-cp310-cp310-win_amd64.whl", hash = "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a"}, 428 | {file = "PyYAML-6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358"}, 429 | {file = "PyYAML-6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1"}, 430 | {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d"}, 431 | {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f"}, 432 | {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782"}, 433 | {file = "PyYAML-6.0-cp311-cp311-win32.whl", hash = "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7"}, 434 | {file = "PyYAML-6.0-cp311-cp311-win_amd64.whl", hash = "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf"}, 435 | {file = "PyYAML-6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86"}, 436 | {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f"}, 437 | {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92"}, 438 | {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4"}, 439 | {file = "PyYAML-6.0-cp36-cp36m-win32.whl", hash = "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293"}, 440 | {file = "PyYAML-6.0-cp36-cp36m-win_amd64.whl", hash = "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57"}, 441 | {file = "PyYAML-6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c"}, 442 | {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0"}, 443 | {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4"}, 444 | {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9"}, 445 | {file = "PyYAML-6.0-cp37-cp37m-win32.whl", hash = "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737"}, 446 | {file = "PyYAML-6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d"}, 447 | {file = "PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b"}, 448 | {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba"}, 449 | {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34"}, 450 | {file = "PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287"}, 451 | {file = "PyYAML-6.0-cp38-cp38-win32.whl", hash = "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78"}, 452 | {file = "PyYAML-6.0-cp38-cp38-win_amd64.whl", hash = "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07"}, 453 | {file = "PyYAML-6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b"}, 454 | {file = "PyYAML-6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174"}, 455 | {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803"}, 456 | {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3"}, 457 | {file = "PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0"}, 458 | {file = "PyYAML-6.0-cp39-cp39-win32.whl", hash = "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb"}, 459 | {file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"}, 460 | {file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, 461 | ] 462 | setuptools = [ 463 | {file = "setuptools-67.7.2-py3-none-any.whl", hash = "sha256:23aaf86b85ca52ceb801d32703f12d77517b2556af839621c641fca11287952b"}, 464 | {file = "setuptools-67.7.2.tar.gz", hash = "sha256:f104fa03692a2602fa0fec6c6a9e63b6c8a968de13e17c026957dd1f53d80990"}, 465 | ] 466 | tomli = [ 467 | {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, 468 | {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, 469 | ] 470 | typing-extensions = [ 471 | {file = "typing_extensions-4.5.0-py3-none-any.whl", hash = "sha256:fb33085c39dd998ac16d1431ebc293a8b3eedd00fd4a32de0ff79002c19511b4"}, 472 | {file = "typing_extensions-4.5.0.tar.gz", hash = "sha256:5cb5f4a79139d699607b3ef622a1dedafa84e115ab0024e0d9c044a9479ca7cb"}, 473 | ] 474 | virtualenv = [ 475 | {file = "virtualenv-20.22.0-py3-none-any.whl", hash = "sha256:48fd3b907b5149c5aab7c23d9790bea4cac6bc6b150af8635febc4cfeab1275a"}, 476 | {file = "virtualenv-20.22.0.tar.gz", hash = "sha256:278753c47aaef1a0f14e6db8a4c5e1e040e90aea654d0fc1dc7e0d8a42616cc3"}, 477 | ] 478 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "single-consumer-queue" 3 | version = "1.1.1" 4 | description = "Asyncio high-performance single consumer queue" 5 | authors = ["Lukas Krocek "] 6 | homepage = "https://github.com/LukasKrocek/single-consumer-queue-python" 7 | license = "MIT" 8 | readme = "README.md" 9 | packages = [{include = "single_consumer_queue"}] 10 | include = ["py.typed"] 11 | 12 | [tool.poetry.dependencies] 13 | python = "^3.10" 14 | 15 | [tool.poetry.dev-dependencies] 16 | pytest = "*" 17 | pytest-asyncio = "*" 18 | pytest-cov = "*" 19 | pre-commit = "*" 20 | mypy = "*" 21 | 22 | [tool.pytest.ini_options] 23 | asyncio_mode="strict" 24 | 25 | [build-system] 26 | requires = ["poetry-core"] 27 | build-backend = "poetry.core.masonry.api" 28 | -------------------------------------------------------------------------------- /single_consumer_queue/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LukasKrocek/single-consumer-queue-python/3dce29d8af57611c3452e841e8e96d5b9f12eaff/single_consumer_queue/__init__.py -------------------------------------------------------------------------------- /single_consumer_queue/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LukasKrocek/single-consumer-queue-python/3dce29d8af57611c3452e841e8e96d5b9f12eaff/single_consumer_queue/py.typed -------------------------------------------------------------------------------- /single_consumer_queue/queue.py: -------------------------------------------------------------------------------- 1 | import abc 2 | import asyncio 3 | import collections 4 | from collections.abc import AsyncGenerator, Sized 5 | from heapq import heappop, heappush 6 | from typing import Deque, Generic, TypeVar 7 | 8 | T = TypeVar("T") 9 | 10 | 11 | class AbstractSingleConsumerQueue(Generic[T]): 12 | _queue: Sized 13 | 14 | def __init__(self) -> None: 15 | self._waiter: asyncio.Future[None] | None = None 16 | self._consuming_lock = asyncio.Lock() 17 | self._init() 18 | 19 | @abc.abstractmethod 20 | def _init(self) -> None: 21 | pass 22 | 23 | @abc.abstractmethod 24 | def _get(self) -> T: 25 | pass 26 | 27 | @abc.abstractmethod 28 | def _put(self, item: T) -> None: 29 | pass 30 | 31 | def empty(self) -> bool: 32 | return len(self._queue) == 0 33 | 34 | def _raise_if_locked(self) -> None: 35 | if self._consuming_lock.locked(): 36 | raise RuntimeError("Only one consumer is allowed") 37 | 38 | async def start_consuming(self, max_consecutive_yields: int | None = None) -> AsyncGenerator[T, None]: 39 | """ 40 | max_consecutive_yields: 41 | prevents blocking of other tasks by yielding control to the event loop after max_consecutive_yields 42 | The maximum number of consecutive yields before calling asyncio.sleep(0) to yield control to the event loop 43 | None will not yield control as long as there are items in the queue 44 | """ 45 | self._raise_if_locked() 46 | consecutive_yield_counter = 0 47 | async with self._consuming_lock: 48 | while True: 49 | if self._queue: 50 | yield self._get() 51 | consecutive_yield_counter += 1 52 | if max_consecutive_yields is not None and consecutive_yield_counter >= max_consecutive_yields: 53 | consecutive_yield_counter = 0 54 | await asyncio.sleep(0) 55 | else: 56 | self._waiter = asyncio.Future() 57 | consecutive_yield_counter = 0 58 | await self._waiter 59 | self._waiter = None 60 | 61 | def put_nowait(self, item: T) -> None: 62 | self._put(item) 63 | if self._waiter and not self._waiter.done(): 64 | self._waiter.set_result(None) 65 | 66 | def get_nowait(self, ignore_lock: bool = False) -> T: 67 | """use ignore_lock = True when you know that consuming task is already cancelling""" 68 | if not ignore_lock: 69 | self._raise_if_locked() 70 | return self._get() 71 | 72 | async def get(self) -> T: 73 | """ 74 | get is slow and should not be used in a loop, as it needs to acquire lock every time it's called 75 | use start_consuming generator instead if you want to consume items in a loop 76 | """ 77 | self._raise_if_locked() 78 | async with self._consuming_lock: 79 | if self._queue: 80 | return self._get() 81 | self._waiter = asyncio.Future() 82 | await self._waiter 83 | self._waiter = None 84 | return self._get() 85 | 86 | 87 | class SingleConsumerQueue(AbstractSingleConsumerQueue[T]): 88 | def _init(self) -> None: 89 | self._queue: Deque[T] = collections.deque() 90 | 91 | def _get(self) -> T: 92 | return self._queue.popleft() 93 | 94 | def _put(self, item: T) -> None: 95 | self._queue.append(item) 96 | 97 | 98 | class SingleConsumerPriorityQueue(AbstractSingleConsumerQueue[T]): 99 | def _init(self) -> None: 100 | self._queue: list[T] = [] 101 | 102 | def _put(self, item: T) -> None: 103 | heappush(self._queue, item) 104 | 105 | def _get(self) -> T: 106 | return heappop(self._queue) 107 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LukasKrocek/single-consumer-queue-python/3dce29d8af57611c3452e841e8e96d5b9f12eaff/tests/__init__.py -------------------------------------------------------------------------------- /tests/test_single_consumer_queue.py: -------------------------------------------------------------------------------- 1 | # pylint:disable=protected-access 2 | import asyncio 3 | import timeit 4 | from asyncio import PriorityQueue 5 | from time import perf_counter 6 | 7 | import pytest 8 | 9 | from single_consumer_queue.queue import SingleConsumerPriorityQueue 10 | 11 | 12 | @pytest.mark.asyncio 13 | async def test_put_and_get() -> None: 14 | queue = SingleConsumerPriorityQueue[int]() 15 | queue.put_nowait(1) 16 | assert queue._queue == [1] 17 | 18 | gen = queue.start_consuming() 19 | result = await anext(gen) 20 | assert result == 1 21 | assert len(queue._queue) == 0 22 | 23 | waiting_task = asyncio.create_task(asyncio.wait_for(anext(gen), timeout=0.01)) 24 | await asyncio.sleep(0.001) 25 | assert queue._waiter is not None and not queue._waiter.done() 26 | with pytest.raises(asyncio.TimeoutError): 27 | await waiting_task 28 | assert queue._waiter is not None and queue._waiter.cancelled() 29 | 30 | 31 | @pytest.mark.asyncio 32 | async def test_put_sets_future_result_when_future_exists() -> None: 33 | my_q = SingleConsumerPriorityQueue[int]() 34 | my_q._waiter = asyncio.Future() 35 | assert not my_q._waiter.done() 36 | my_q.put_nowait(1) 37 | assert my_q._waiter.done() 38 | 39 | assert my_q._queue == [1] 40 | assert my_q._waiter.result() is None 41 | 42 | 43 | @pytest.mark.asyncio 44 | async def test_put_when_future_is_cancelled() -> None: 45 | future = asyncio.Future[None]() 46 | future.cancel() 47 | my_q = SingleConsumerPriorityQueue[int]() 48 | my_q._waiter = future 49 | my_q.put_nowait(1) 50 | assert my_q._queue == [1] 51 | assert my_q._waiter is future 52 | 53 | 54 | @pytest.mark.asyncio 55 | async def test_get_creates_future_and_waits() -> None: 56 | queue = SingleConsumerPriorityQueue[int]() 57 | gen = queue.start_consuming() 58 | queue_get_task = asyncio.create_task(asyncio.wait_for(anext(gen), timeout=0.01)) 59 | await asyncio.sleep(0.001) 60 | assert not queue_get_task.done() 61 | assert queue._waiter is not None and not queue._waiter.done() 62 | 63 | queue.put_nowait(1) 64 | result = await queue_get_task 65 | assert result == 1 66 | assert len(queue._queue) == 0 67 | assert queue._waiter is None 68 | 69 | 70 | @pytest.mark.asyncio 71 | async def test_second_waiter_raises_error() -> None: 72 | async def consume(q: SingleConsumerPriorityQueue[int]) -> None: 73 | async for _ in q.start_consuming(): 74 | pass 75 | 76 | queue = SingleConsumerPriorityQueue[int]() 77 | get_task = asyncio.create_task(consume(queue)) 78 | await asyncio.sleep(0) 79 | with pytest.raises(RuntimeError): 80 | await queue.get() 81 | 82 | with pytest.raises(RuntimeError): 83 | queue.get_nowait() 84 | 85 | with pytest.raises(RuntimeError): 86 | async for _ in queue.start_consuming(): 87 | pass 88 | 89 | get_task.cancel() 90 | 91 | 92 | @pytest.mark.asyncio 93 | @pytest.mark.skip 94 | async def test_perf() -> None: 95 | my_q = SingleConsumerPriorityQueue[int]() 96 | t1 = perf_counter() 97 | my_q.put_nowait(1) 98 | async for i in my_q.start_consuming(): 99 | my_q.put_nowait(i + 1) 100 | if i > 1_000_000: 101 | break 102 | single_consumer_priority_queue_time = perf_counter() - t1 103 | # Custom Queue time 0.45637712499592453 104 | print(f"Custom Queue time {single_consumer_priority_queue_time}") 105 | 106 | q = PriorityQueue[int]() 107 | t1 = perf_counter() 108 | for _ in range(1_000_000): 109 | q.put_nowait(1) 110 | await q.get() 111 | built_in_priority_queue_time = perf_counter() - t1 112 | # Built-in Queue time 1.11714420899807 113 | print(f"Built-in Queue time {built_in_priority_queue_time}") 114 | 115 | # single consumer priority is roughly 3 times faster than built-in priority queue, in this test for python 3.10 116 | assert single_consumer_priority_queue_time < built_in_priority_queue_time / 2 117 | 118 | 119 | @pytest.mark.asyncio 120 | @pytest.mark.skip 121 | async def test_perf_2() -> None: 122 | async def custom_queue_consumer(q: SingleConsumerPriorityQueue[int]) -> None: 123 | counter = 0 124 | async for _ in q.start_consuming(): 125 | counter += 1 126 | if counter == 999_999: 127 | return 128 | 129 | async def built_in_queue_consumer(q: PriorityQueue[int]) -> None: 130 | counter = 1_000_000 131 | for _ in range(counter): 132 | await q.get() 133 | return 134 | 135 | single_queue = SingleConsumerPriorityQueue[int]() 136 | task = asyncio.create_task(custom_queue_consumer(single_queue)) 137 | t1 = perf_counter() 138 | putting_time = timeit.timeit("single_queue.put_nowait(1)", globals={**globals(), **locals()}) 139 | await task 140 | single_consumer_priority_queue_time = perf_counter() - t1 141 | # Custom Queue put no wait 1m times: 0.2097, putting + getting 1m items 0.6893 142 | print( 143 | f"Custom Queue put no wait 1m times: {putting_time:.4f}, " 144 | f"putting + getting 1m items {single_consumer_priority_queue_time:.4f}" 145 | ) 146 | 147 | queue = PriorityQueue[int]() 148 | task2 = asyncio.create_task(built_in_queue_consumer(queue)) 149 | t1 = perf_counter() 150 | putting_time = timeit.timeit("queue.put_nowait(1)", globals={**globals(), **locals()}) 151 | await task2 152 | built_in_priority_queue_time = perf_counter() - t1 153 | # Built-in Queue put no wait 1m times: 0.5601, putting + getting 1m items 1.3322 154 | print( 155 | f"Built-in Queue put no wait 1m times: {putting_time:.4f}, " 156 | f"putting + getting 1m items {built_in_priority_queue_time:.4f}" 157 | ) 158 | 159 | # single consumer priority is roughly 2 times faster than built-in priority queue, in this test for python 3.10 160 | assert single_consumer_priority_queue_time < built_in_priority_queue_time * 2 / 3 161 | --------------------------------------------------------------------------------