diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 670fd15..169a907 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.11", "3.12"] steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 829e07b..673eb99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## unreleased + +* [Support python 3.12, drop 3.9 and 3.10](https://github.com/anna-money/aio-background/pull/231) + + ## v0.0.9 (2022-11-18) * [Support python 3.11] diff --git a/Makefile b/Makefile index db8b0b4..634279b 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ test: @python3 -m pytest -vv --rootdir tests . pyenv: - echo aio-background > .python-version && pyenv install -s 3.11 && pyenv virtualenv -f 3.11 aio-background + echo aio-background > .python-version && pyenv install -s 3.12 && pyenv virtualenv -f 3.12 aio-background pyenv-delete: pyenv virtualenv-delete -f aio-background diff --git a/aio_background/aiohttp.py b/aio_background/aiohttp.py index ac63382..7cf165b 100644 --- a/aio_background/aiohttp.py +++ b/aio_background/aiohttp.py @@ -1,5 +1,5 @@ import uuid -from typing import Any, AsyncIterator, Callable, Coroutine, Union +from typing import Any, AsyncIterator, Callable, Coroutine import aiohttp.web @@ -9,7 +9,7 @@ def setup_ctx( - job_or_factory: Union[Job, Callable[[aiohttp.web.Application], Coroutine[Any, Any, Job]]], + job_or_factory: Job | Callable[[aiohttp.web.Application], Coroutine[Any, Any, Job]], *, timeout: float = 0.5, ) -> Callable[[aiohttp.web.Application], AsyncIterator[None]]: diff --git a/aio_background/job.py b/aio_background/job.py index 5f62d9a..a6b42d0 100644 --- a/aio_background/job.py +++ b/aio_background/job.py @@ -15,36 +15,36 @@ async def close(self, *, timeout: float = 0.5) -> bool: ... class SingleTaskJob(Job): - __slots__ = ("_task",) + __slots__ = ("__task",) def __init__(self, task: asyncio.Task[None]): - self._task = task + self.__task = task @property def is_running(self) -> bool: - return not self._task.done() + return not self.__task.done() async def close(self, *, timeout: float = 0.5) -> bool: - if self._task.done(): + if self.__task.done(): return True - self._task.cancel() - await asyncio.wait({self._task}, timeout=timeout) - return self._task.done() + self.__task.cancel() + await asyncio.wait({self.__task}, timeout=timeout) + return self.__task.done() class CombinedJob(Job): - __slots__ = ("_jobs",) + __slots__ = ("__jobs",) def __init__(self, jobs: Collection[Job]): - self._jobs = jobs + self.__jobs = jobs @property def is_running(self) -> bool: - return all(job.is_running for job in self._jobs) + return all(job.is_running for job in self.__jobs) async def close(self, *, timeout: float = 0.5) -> bool: - tasks = [asyncio.create_task(job.close(timeout=timeout)) for job in self._jobs] + tasks = [asyncio.create_task(job.close(timeout=timeout)) for job in self.__jobs] closed = True for task in tasks: closed &= await task diff --git a/setup.py b/setup.py index 678f863..0d51d39 100644 --- a/setup.py +++ b/setup.py @@ -37,8 +37,8 @@ def read_version(): long_description=long_description, long_description_content_type="text/markdown", platforms=["macOS", "POSIX", "Windows"], - author="Yury Pliner", - python_requires=">=3.9", + author="Iurii Pliner", + python_requires=">=3.11", project_urls={}, author_email="yury.pliner@gmail.com", license="MIT", @@ -52,9 +52,8 @@ def read_version(): "Intended Audience :: Developers", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Operating System :: OS Independent", "Environment :: Web Environment", "Development Status :: 5 - Production/Stable",