Skip to content

Commit

Permalink
Add Python 3.12 support (#64)
Browse files Browse the repository at this point in the history
* ci: Include Python 3.12 as one of primary test targets
* doc: Mention the child watcher API deprecation issue
* ci: Upgrade black (23.7.0 -> 23.9.1)
* setup: Update the trove classifier to include Python 3.12
  • Loading branch information
achimnol authored Dec 9, 2023
1 parent b2eb184 commit aea4c20
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
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
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

0 comments on commit aea4c20

Please sign in to comment.