Skip to content

Commit ac3c213

Browse files
authored
Merge pull request #13 from zhanghaitao3/master
Fix multiple test failures
2 parents 2cd00d5 + 2ad6852 commit ac3c213

File tree

14 files changed

+104
-178
lines changed

14 files changed

+104
-178
lines changed

.github/workflows/release.yml

Lines changed: 35 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ on:
55
tags:
66
- "*"
77

8-
permissions:
9-
contents: write
10-
118
jobs:
129
build-sdist:
1310
runs-on: ubuntu-latest
@@ -31,9 +28,10 @@ jobs:
3128
pip install -U setuptools wheel pip
3229
python setup.py sdist
3330
34-
- uses: actions/upload-artifact@v4
31+
- name: Upload sdist artifact
32+
uses: actions/upload-artifact@v4
3533
with:
36-
name: dist-sdist
34+
name: dist-sdist
3735
path: dist/*.tar.*
3836

3937
build-wheels-matrix:
@@ -90,121 +88,65 @@ jobs:
9088
env:
9189
CIBW_BUILD_VERBOSITY: 1
9290

93-
- uses: actions/upload-artifact@v4
91+
- name: Upload wheel artifacts
92+
uses: actions/upload-artifact@v4
9493
with:
9594
name: dist-wheels-${{ matrix.only }}
9695
path: wheelhouse/*.whl
9796

98-
merge-artifacts:
99-
runs-on: ubuntu-latest
100-
needs: [build-sdist, build-wheels]
101-
steps:
102-
- name: Merge Artifacts
103-
uses: actions/upload-artifact/merge@v4
104-
with:
105-
name: dist
106-
delete-merged: true
107-
108-
publish-docs:
109-
needs: [build-sdist, build-wheels]
110-
runs-on: ubuntu-latest
111-
112-
env:
113-
PIP_DISABLE_PIP_VERSION_CHECK: 1
114-
115-
steps:
116-
- name: Checkout source
117-
uses: actions/checkout@v4
118-
with:
119-
fetch-depth: 5
120-
submodules: true
121-
122-
- name: Set up Python
123-
uses: actions/setup-python@v5
124-
with:
125-
python-version: "3.x"
126-
127-
- name: Build docs
128-
run: |
129-
pip install -e .[docs]
130-
make htmldocs
131-
132-
- name: Checkout gh-pages
133-
uses: actions/checkout@v4
134-
with:
135-
fetch-depth: 5
136-
ref: gh-pages
137-
path: docs/gh-pages
138-
139-
- name: Sync docs
140-
run: |
141-
rsync -a docs/_build/html/ docs/gh-pages/current/
142-
143-
- name: Commit and push docs
144-
uses: magicstack/gha-commit-and-push@master
145-
with:
146-
target_branch: gh-pages
147-
workdir: docs/gh-pages
148-
commit_message: Automatic documentation update
149-
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
150-
ssh_key: ${{ secrets.RELEASE_BOT_SSH_KEY }}
151-
gpg_key: ${{ secrets.RELEASE_BOT_GPG_KEY }}
152-
gpg_key_id: "5C468778062D87BF!"
153-
15497
publish:
155-
needs: [build-sdist, build-wheels, publish-docs]
98+
needs: [build-sdist, build-wheels]
15699
runs-on: ubuntu-latest
157100

158101
environment:
159102
name: pypi
160103
url: https://pypi.org/p/async_gaussdb
161-
permissions:
162-
id-token: write
163-
attestations: write
164-
contents: write
165-
deployments: write
166104

167105
steps:
168106
- uses: actions/checkout@v4
169107
with:
170108
fetch-depth: 5
171109
submodules: false
172110

173-
- uses: actions/download-artifact@v4
111+
- name: Download sdist artifact
112+
uses: actions/download-artifact@v4
113+
with:
114+
name: dist-sdist
115+
path: dist/
116+
117+
- name: Download all wheel artifacts
118+
uses: actions/download-artifact@v4
174119
with:
175-
name: dist
120+
pattern: dist-wheels-*
176121
path: dist/
177122

178123
- name: Extract Release Version
179124
id: relver
180125
run: |
181126
set -e
182-
# 从标签中提取版本
183127
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
184128
185-
- name: Merge and tag the PR
186-
uses: edgedb/action-release/merge@master
187-
with:
188-
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
189-
ssh_key: ${{ secrets.RELEASE_BOT_SSH_KEY }}
190-
gpg_key: ${{ secrets.RELEASE_BOT_GPG_KEY }}
191-
gpg_key_id: "5C468778062D87BF!"
192-
tag_name: v${{ steps.relver.outputs.version }}
193-
194-
- name: Publish Github Release
195-
uses: elprans/gh-action-create-release@master
196-
env:
197-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129+
- name: Prepare all_dist directory
130+
run: mkdir all_dist
131+
132+
- name: Move artifacts to all_dist
133+
run: |
134+
ls dist/dist-wheels-cp310-macosx_arm64/
135+
mv dist/**/*.whl all_dist/
136+
mv dist/*.tar.gz all_dist/
137+
ls -l all_dist/
138+
139+
- name: Upload all dist/* to GitHub Release
140+
uses: softprops/action-gh-release@v1
198141
with:
199-
tag_name: v${{ steps.relver.outputs.version }}
200-
release_name: v${{ steps.relver.outputs.version }}
201-
target: ${{ github.ref }} # 使用提交的标签作为目标
202-
body: "Release v${{ steps.relver.outputs.version }}"
142+
files: all_dist/*
203143

204-
- run: |
205-
ls -al dist/
206144

207145
- name: Upload to PyPI
208-
uses: pypa/gh-action-pypi-publish@release/v1
209-
with:
210-
attestations: true
146+
if: startsWith(github.ref, 'refs/tags/')
147+
run: |
148+
pip install --upgrade twine setuptools wheel twine packaging
149+
twine upload all_dist/*
150+
env:
151+
TWINE_USERNAME: __token__
152+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ jobs:
7474
[ "$RUNNER_OS" = "Linux" ] && .github/workflows/install-krb5.sh
7575
python -m pip install -U pip setuptools wheel
7676
python -m pip install -e .[test]
77+
# 添加 uvloop 安装
78+
if [ "${{ matrix.loop }}" = "uvloop" ]; then
79+
python -m pip install uvloop
80+
fi
7781
7882
- name: Wait for openGauss to be ready
7983
env:

README.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
async_gaussdb -- A fast GaussDB/openGauss Database Client Library for Python/asyncio
22
=====================================================================================
33

4-
.. image:: https://github.com/MagicStack/async_gaussdb/workflows/Tests/badge.svg
5-
:target: https://github.com/MagicStack/async_gaussdb/actions?query=workflow%3ATests+branch%3Amaster
6-
:alt: GitHub Actions status
7-
.. image:: https://img.shields.io/pypi/v/async_gaussdb.svg
8-
:target: https://pypi.python.org/pypi/async_gaussdb
9-
104
**async_gaussdb** is a database interface library designed specifically for
115
GaussDB and openGauss databases with Python/asyncio. This fork of async_gaussdb is
126
optimized for GaussDB/openGauss compatibility, including native SHA256
@@ -86,7 +80,7 @@ Basic Usage
8680
8781
8882
GaussDB/openGauss Specific Features
89-
----------------------------------
83+
-----------------------------------
9084

9185
This library includes enhanced support for GaussDB and openGauss databases:
9286

@@ -115,5 +109,5 @@ This library includes enhanced support for GaussDB and openGauss databases:
115109
116110
asyncio.run(run())
117111
118-
119-
asyncpg is developed and distributed under the Apache 2.0 license.
112+
asyncpg is developed and distributed under the Apache 2.0 license
113+
by MagicStack Inc. and the HuaweiCloudDeveloper team.

async_gaussdb/protocol/protocol.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ cdef class BaseProtocol(CoreProtocol):
5151

5252
bint _is_ssl
5353

54+
object _pending_result
55+
5456
PreparedStatementState statement
5557

5658
cdef get_connection(self)

async_gaussdb/protocol/protocol.pyx

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ cdef class BaseProtocol(CoreProtocol):
102102

103103
self._is_ssl = False
104104

105+
self._pending_result = None
106+
105107
try:
106108
self.create_future = loop.create_future
107109
except AttributeError:
@@ -414,7 +416,10 @@ cdef class BaseProtocol(CoreProtocol):
414416
self._request_cancel()
415417
# Make asyncio shut up about unretrieved
416418
# QueryCanceledError
417-
waiter.add_done_callback(lambda f: f.exception())
419+
if waiter and not waiter.done():
420+
waiter.cancel()
421+
elif waiter and waiter.done() and not waiter.cancelled():
422+
waiter.exception()
418423
raise
419424

420425
# done will be True upon receipt of CopyDone.
@@ -424,6 +429,7 @@ cdef class BaseProtocol(CoreProtocol):
424429
waiter = self._new_waiter(timer.get_remaining_budget())
425430

426431
finally:
432+
self._pending_result = None
427433
self.resume_reading()
428434

429435
return status_msg
@@ -776,6 +782,14 @@ cdef class BaseProtocol(CoreProtocol):
776782
self.abort()
777783

778784
cdef _new_waiter(self, timeout):
785+
if self._pending_result is not None:
786+
res = self._pending_result
787+
self._pending_result = None
788+
self.resume_reading()
789+
waiter = self.loop.create_future()
790+
waiter.set_result(res)
791+
return waiter
792+
779793
if self.waiter is not None:
780794
raise apg_exc.InterfaceError(
781795
'cannot perform operation: another operation is in progress')
@@ -848,10 +862,31 @@ cdef class BaseProtocol(CoreProtocol):
848862
waiter = self.waiter
849863
self.waiter = None
850864

851-
if PG_DEBUG:
852-
if waiter is None:
865+
if waiter is None:
866+
if PG_DEBUG:
853867
raise apg_exc.InternalClientError('_on_result: waiter is None')
868+
869+
if self.state == PROTOCOL_COPY_OUT_DATA or \
870+
self.state == PROTOCOL_COPY_OUT_DONE:
871+
872+
copy_done = self.state == PROTOCOL_COPY_OUT_DONE
873+
if copy_done:
874+
status_msg = self.result_status_msg.decode(self.encoding)
875+
else:
876+
status_msg = None
877+
878+
self.pause_reading()
879+
if self._pending_result is not None:
880+
old_data, old_done, old_status = self._pending_result
881+
current_data = self.result if self.result is not None else b''
882+
merged_data = (old_data if old_data is not None else b'') + current_data
883+
self._pending_result = (merged_data, copy_done, status_msg)
884+
else:
885+
self._pending_result = (self.result, copy_done, status_msg)
854886

887+
return
888+
else:
889+
return
855890
if waiter.cancelled():
856891
return
857892

pyproject.toml

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
[project]
22
name = "async_gaussdb"
33
description = "An asyncio GaussDB driver"
4-
authors = [{name = "MagicStack Inc", email = "hello@magic.io"}]
54
requires-python = '>=3.8.0'
65
readme = "README.rst"
7-
license = {text = "Apache License, Version 2.0"}
6+
license = {text = "Apache-2.0"}
87
dynamic = ["version"]
98
keywords = [
109
"database",
@@ -39,16 +38,6 @@ gssauth = [
3938
'gssapi; platform_system != "Windows"',
4039
'sspilib; platform_system == "Windows"',
4140
]
42-
test = [
43-
'flake8~=6.1',
44-
'flake8-pyi~=24.1.0',
45-
'distro~=1.9.0',
46-
'uvloop>=0.15.3; platform_system != "Windows" and python_version < "3.14.0"',
47-
'gssapi; platform_system == "Linux"',
48-
'k5test; platform_system == "Linux"',
49-
'sspilib; platform_system == "Windows"',
50-
'mypy~=1.8.0',
51-
]
5241
docs = [
5342
'Sphinx~=8.1.3',
5443
'sphinx_rtd_theme>=1.2.2',
@@ -71,50 +60,6 @@ include = ["async_gaussdb", "async_gaussdb.*"]
7160
[tool.setuptools.exclude-package-data]
7261
"*" = ["*.c", "*.h"]
7362

74-
[tool.cibuildwheel]
75-
build-frontend = "build"
76-
test-extras = "test"
77-
78-
[tool.cibuildwheel.macos]
79-
before-all = ".github/workflows/install-gaussdb.sh"
80-
test-command = "python {project}/tests/__init__.py"
81-
82-
[tool.cibuildwheel.windows]
83-
test-command = "python {project}\\tests\\__init__.py"
84-
85-
[tool.cibuildwheel.linux]
86-
before-all = """
87-
.github/workflows/install-gaussdb.sh \
88-
&& .github/workflows/install-krb5.sh \
89-
"""
90-
test-command = """\
91-
PY=`which python` \
92-
&& chmod -R go+rX "$(dirname $(dirname $(dirname $PY)))" \
93-
&& su -l apgtest -c "$PY {project}/tests/__init__.py" \
94-
"""
95-
96-
[tool.pytest.ini_options]
97-
addopts = "--capture=no --assert=plain --strict-markers --tb=native --import-mode=importlib"
98-
testpaths = "tests"
99-
filterwarnings = "default"
100-
101-
[tool.coverage.run]
102-
branch = true
103-
plugins = ["Cython.Coverage"]
104-
parallel = true
105-
source = ["async_gaussdb/", "tests/"]
106-
omit = ["*.pxd"]
107-
108-
[tool.coverage.report]
109-
exclude_lines = [
110-
"pragma: no cover",
111-
"def __repr__",
112-
"if debug",
113-
"raise NotImplementedError",
114-
"if __name__ == .__main__.",
115-
]
116-
show_missing = true
117-
11863
[tool.mypy]
11964
exclude = [
12065
"^.eggs",
@@ -145,4 +90,4 @@ module = [
14590
"async_gaussdb.transaction",
14691
"async_gaussdb.utils",
14792
]
148-
ignore_errors = true
93+
ignore_errors = true

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,5 +249,5 @@ def finalize_options(self):
249249
extra_link_args=LDFLAGS),
250250
],
251251
cmdclass={'build_ext': build_ext, 'build_py': build_py, 'sdist': sdist},
252-
setup_requires=setup_requires,
252+
setup_requires=setup_requires
253253
)

0 commit comments

Comments
 (0)