Skip to content

Commit

Permalink
Support only python 3.11 and 3.12 (#231)
Browse files Browse the repository at this point in the history
* Support only python 3.11 and 3.12

* Add to changelog
  • Loading branch information
Pliner authored Sep 7, 2024
1 parent 119d3e1 commit fff148a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions aio_background/aiohttp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import uuid
from typing import Any, AsyncIterator, Callable, Coroutine, Union
from typing import Any, AsyncIterator, Callable, Coroutine

import aiohttp.web

Expand All @@ -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]]:
Expand Down
22 changes: 11 additions & 11 deletions aio_background/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]",
license="MIT",
Expand All @@ -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",
Expand Down

0 comments on commit fff148a

Please sign in to comment.