Skip to content
Open
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
39 changes: 13 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,19 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
steps:
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
run: |
pip install -U pip poetry
poetry config virtualenvs.create false
pip3 install wheel setuptools pip --upgrade
allow-prereleases: true
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Run ci
run: make ci
run: uv run make ci

ci_mariadb:
runs-on: ubuntu-latest
services:
Expand All @@ -48,22 +42,15 @@ jobs:
options: --health-cmd="mariadb-admin ping -uroot -p${MYSQL_ROOT_PASSWORD}" --health-interval 10s --health-timeout 5s --health-retries 5
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
steps:
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
run: |
pip install -U pip poetry
poetry config virtualenvs.create false
pip3 install wheel setuptools pip --upgrade
allow-prereleases: true
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Run ci
run: make ci
run: uv run make ci
4 changes: 2 additions & 2 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: abatilo/actions-poetry@v3
- uses: astral-sh/setup-uv@v6
- name: Build
run: poetry build
run: uv build
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ py_warn = PYTHONDEVMODE=1
MYSQL_PASS ?= "123456"

up:
@poetry update
@uv lock --upgrade

deps:
@poetry install --all-groups
uv sync --active --inexact --all-groups --all-extras $(options)

_style:
@ruff format $(checkfiles)
Expand All @@ -30,7 +30,7 @@ clean:
@rm -rf *.so && rm -rf build && rm -rf dist && rm -rf asyncmy/*.c && rm -rf asyncmy/*.so && rm -rf asyncmy/*.html

build: clean
@poetry build
@uv build

benchmark: deps
@python benchmark/main.py
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ async def run():
await cursor.execute("SELECT 1")
ret = await cursor.fetchone()
assert ret == (1,)
pool.close()
await pool.wait_closed()
await pool.aclose()

if __name__ == '__main__':
asyncio.run(run())
Expand Down
8 changes: 6 additions & 2 deletions asyncmy/pool.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ class Pool(asyncio.AbstractServer):

self._closed = True

async def aclose(self):
"""Close pool and wait for closing all pool's connections."""
self.close()
await self.wait_closed()

def acquire(self):
"""Acquire free connection from the pool."""
coro = self._acquire()
Expand Down Expand Up @@ -194,8 +199,7 @@ class Pool(asyncio.AbstractServer):
return self

async def __aexit__(self, exc_type, exc_val, exc_tb):
self.close()
await self.wait_closed()
await self.aclosed()


def create_pool(
Expand Down
3 changes: 2 additions & 1 deletion asyncmy/version.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__VERSION__ = "0.2.10"
__version__ = "0.2.10"
__VERSION__ = __version__
17 changes: 4 additions & 13 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
from distutils.command.build_ext import build_ext

from Cython.Build import cythonize


def build(setup_kwargs):
setup_kwargs.update(
{
"ext_modules": cythonize(
[
"asyncmy/*.pyx",
],
compiler_directives={"language_level": 3},
),
"cmdclass": {"build_ext": build_ext},
}
def pdm_build_update_setup_kwargs(context, setup_kwargs) -> None:
setup_kwargs["ext_modules"] = cythonize(
["asyncmy/*.pyx"],
language_level="3",
)
Loading