Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python 3.12 support #64

Merged
merged 7 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ jobs:
os: [ubuntu-latest, macos-latest]
python-version:
- "3.11"
experimental: [false]
include:
- python-version: "~3.12.0-0"
experimental: true
- "3.12"
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ celerybeat-schedule
.envrc

# virtualenv
.venv/
venv/
ENV/

Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
Expand Down
1 change: 1 addition & 0 deletions changes/64.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add Python 3.12 support
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ classifiers =
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Topic :: Software Development
url = https://github.com/achimnol/aiotools
project_urls =
Expand All @@ -41,7 +42,7 @@ build =
twine~=4.0
towncrier~=22.12
test =
pytest~=7.2.2
pytest~=7.4.2
pytest-asyncio~=0.21
pytest-cov
pytest-mock
Expand All @@ -53,7 +54,7 @@ lint =
ruff>=0.0.285
ruff-lsp>=0.0.37
typecheck =
mypy~=1.4.1
mypy~=1.5.1
docs =
sphinx~=4.3
sphinx-rtd-theme~=1.0
Expand Down
26 changes: 14 additions & 12 deletions src/aiotools/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,20 @@ def helper(*args, **kwargs):


def setup_child_watcher(loop: asyncio.AbstractEventLoop) -> None:
try:
watcher_cls = getattr(asyncio, "PidfdChildWatcher", None)
if _has_pidfd and watcher_cls:
watcher = watcher_cls()
asyncio.set_child_watcher(watcher)
else:
# Just get the default child watcher.
watcher = asyncio.get_child_watcher()
if not watcher.is_active():
watcher.attach_loop(loop)
except NotImplementedError:
pass # for uvloop
if sys.version_info < (3, 12, 0):
# see python/cpython#94597 (issue) and python/cpython#98215 (pr)
try:
watcher_cls = getattr(asyncio, "PidfdChildWatcher", None)
if _has_pidfd and watcher_cls:
watcher = watcher_cls()
asyncio.set_child_watcher(watcher)
else:
# Just get the default child watcher.
watcher = asyncio.get_child_watcher()
if not watcher.is_active():
watcher.attach_loop(loop)
except NotImplementedError:
pass # for uvloop


async def cancel_all_tasks() -> None:
Expand Down
3 changes: 1 addition & 2 deletions src/aiotools/taskgroup/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ async def __call__(
exc_type: type[Exception],
exc_obj: Exception,
exc_tb: TracebackType,
) -> None:
...
) -> None: ...


class MultiError(ExceptionGroup):
Expand Down
3 changes: 1 addition & 2 deletions src/aiotools/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

@runtime_checkable
class AsyncClosable(Protocol):
async def close(self) -> None:
...
async def close(self) -> None: ...


# taken from the typeshed
Expand Down
Loading