diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e503b3..082a43b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: needs: lint strategy: matrix: - pyver: ['3.9', '3.10', '3.11'] + pyver: ["3.8", "3.9", "3.10", "3.11", "3.12"] fail-fast: false runs-on: ubuntu-latest timeout-minutes: 15 diff --git a/README.rst b/README.rst index 80db03c..682dafd 100644 --- a/README.rst +++ b/README.rst @@ -31,8 +31,6 @@ Implementation is almost direct port from this patch_. Example ------- -Requires Python 3.5.3+ - .. code:: python import asyncio @@ -53,8 +51,7 @@ Requires Python 3.5.3+ await asyncio.sleep(0.1) - loop = asyncio.get_event_loop() - loop.run_until_complete(go()) + asyncio.run(go()) Fast path @@ -85,5 +82,5 @@ License ``aiorwlock`` is offered under the Apache 2 license. -.. _asyncio: http://docs.python.org/3.8/library/asyncio.html +.. _asyncio: http://docs.python.org/3/library/asyncio.html .. _patch: http://bugs.python.org/issue8800 diff --git a/aiorwlock/__init__.py b/aiorwlock/__init__.py index a091860..82a4838 100644 --- a/aiorwlock/__init__.py +++ b/aiorwlock/__init__.py @@ -1,14 +1,7 @@ import asyncio import threading from collections import deque -from typing import Any, Deque, List, Optional, Tuple - -Loop = asyncio.AbstractEventLoop -OptLoop = Optional[Loop] - -# silence LGTM service alerts -Future = asyncio.Future -Task = asyncio.Task +from typing import Any, Deque, List, Tuple __version__ = '1.3.0' __all__ = ('RWLock',) @@ -28,14 +21,14 @@ class _RWLockCore: def __init__(self, fast: bool): self._do_yield = not fast - self._read_waiters: Deque[Future[None]] = deque() - self._write_waiters: Deque[Future[None]] = deque() + self._read_waiters: Deque[asyncio.Future[None]] = deque() + self._write_waiters: Deque[asyncio.Future[None]] = deque() self._r_state: int = 0 self._w_state: int = 0 # tasks will be few, so a list is not inefficient - self._owning: List[Tuple[Task[Any], int]] = [] + self._owning: List[Tuple[asyncio.Task[Any], int]] = [] - def _get_loop(self) -> Loop: + def _get_loop(self) -> asyncio.AbstractEventLoop: """ From: https://github.com/python/cpython/blob/3.12/Lib/asyncio/mixins.py """ diff --git a/examples/context_manager.py b/examples/context_manager.py index a17e1a5..51be53e 100644 --- a/examples/context_manager.py +++ b/examples/context_manager.py @@ -17,5 +17,4 @@ async def go(): await asyncio.sleep(0.1) -loop = asyncio.get_event_loop() -loop.run_until_complete(go()) +asyncio.run(go()) diff --git a/examples/simple.py b/examples/simple.py index cb03cf0..625cbee 100644 --- a/examples/simple.py +++ b/examples/simple.py @@ -25,5 +25,4 @@ async def go(): rwlock.writer_lock.release() -loop = asyncio.get_event_loop() -loop.run_until_complete(go()) +asyncio.run(go()) diff --git a/requirements-dev.txt b/requirements-dev.txt index 251c50a..cbbbe1c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,6 @@ bandit==1.7.6; implementation_name=="cpython" black==23.12.1; implementation_name=="cpython" flake8-bugbear==24.1.17; implementation_name=="cpython" -flake8-quotes==3.3.2; implementation_name=="cpython" flake8==7.0.0; implementation_name=="cpython" isort==5.13.2; implementation_name=="cpython" mypy==1.8.0; implementation_name=="cpython" diff --git a/setup.py b/setup.py index 6464267..483c54a 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,6 @@ from setuptools import setup -install_requires = [] - def read(f): return open(os.path.join(os.path.dirname(__file__), f)).read().strip() @@ -27,10 +25,11 @@ def read_version(): 'License :: OSI Approved :: Apache Software License', 'Intended Audience :: Developers', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", 'Operating System :: OS Independent', 'Development Status :: 4 - Beta', 'Framework :: AsyncIO', @@ -55,10 +54,10 @@ def read_version(): download_url='https://pypi.python.org/pypi/aiorwlock', license='Apache 2', packages=['aiorwlock'], - install_requires=install_requires, + install_requires=(), keywords=['aiorwlock', 'lock', 'asyncio'], zip_safe=True, project_urls=project_urls, - python_requires='>=3.7.0', + python_requires=">=3.8", include_package_data=True, ) diff --git a/tests/test_corner_cases.py b/tests/test_corner_cases.py index 7543df6..42f20c9 100644 --- a/tests/test_corner_cases.py +++ b/tests/test_corner_cases.py @@ -166,7 +166,6 @@ async def write_wait(lock): seq.append('FIN1') async def write(lock): - await asyncio.sleep(0) # PY36 seems to run tasks in the wrong order. async with lock.writer: seq.append('START2') await asyncio.sleep(0.1)