Skip to content

fix: Connection.close() skips cursors when more than one is open #685

fix: Connection.close() skips cursors when more than one is open

fix: Connection.close() skips cursors when more than one is open #685

Workflow file for this run

on:
push:
branches: [master]
tags: ['*']
pull_request:
name: build
concurrency:
# One lane per workflow + PR; non-PR pushes fall back to run_id (never cancel each other)
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
tests:
runs-on: ubuntu-22.04
env:
CLICKHOUSE_VERSION: ${{ matrix.clickhouse-version }}
strategy:
matrix:
use-numpy:
- 0
use-arrow:
- 0
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
- "pypy-3.9"
- "pypy-3.10"
clickhouse-version:
- 25.5.6.14
- 24.4.1
- 24.1.8.22
- 24.1.7.18
- 24.1.5.6
- 23.9.3.12
- 23.2.6.34
- 22.9.5.25
- 22.2.3.5
- 21.12.3.32
- 21.9.3.30
- 21.4.6.55
- 21.3.10.1
- 21.2.10.48
- 21.1.9.41
- 20.11.2.1
- 20.10.2.20
- 20.9.3.45
- 20.8.4.11
- 20.7.4.11
- 20.6.8.5
- 20.5.5.74
- 20.4.9.110
- 20.3.20.6
- 19.16.17.80
- 19.15.3.6
- 19.9.2.4 # allow_suspicious_low_cardinality_types
- 19.8.3.8 # SimpleAggregateFunction
include:
- clickhouse-version: 20.3.20.6
use-numpy: 1
python-version: 3.9
# Oldest supported server + oldest pyarrow/numpy resolvable
# on Python 3.9.
- clickhouse-version: 20.3.20.6
use-numpy: 1
use-arrow: 1
python-version: 3.9
- clickhouse-version: 25.5.6.14
use-numpy: 1
use-arrow: 1
python-version: "3.12"
# PyArrow without numpy/pandas: plain conversion paths only.
- clickhouse-version: 25.5.6.14
use-numpy: 0
use-arrow: 1
python-version: "3.13"
name: ${{ matrix.python-version }} CH=${{ matrix.clickhouse-version }} NUMPY=${{ matrix.use-numpy }} ARROW=${{ matrix.use-arrow }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
# - name: Login to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Install flake8
run: |
pip install --upgrade pip setuptools wheel
pip install flake8 flake8-print
- name: Run flake8
run: flake8
- name: Start ClickHouse server and client containers
run: |
if [[ "21.7" = "`echo -e "21.7\n${{ matrix.clickhouse-version }}" | sort -V | head -n1`" ]]; then echo "ORG=clickhouse"; else echo "ORG=yandex" ; fi >> tests/.env
if [[ "21.10" = "`echo -e "21.10\n${{ matrix.clickhouse-version }}" | sort -V | head -n1`" ]]; then echo "TOP_LEVEL=clickhouse"; else echo "TOP_LEVEL=yandex" ; fi >> tests/.env
docker compose -f tests/docker-compose.yml up -d
- name: Setup clickhouse-client proxy for docker
run: |
# Faking clickhouse-client real communication with container via docker exec.
echo -e '#!/bin/bash\n\ndocker exec -e "`env | grep ^TZ=`" test-clickhouse-client clickhouse client "$@"' | sudo tee /usr/local/bin/clickhouse-client > /dev/null
sudo chmod +x /usr/local/bin/clickhouse-client
# Overriding setup.cfg. Set host=clickhouse-server
sed -i 's/^host=localhost$/host=clickhouse-server/' setup.cfg
# Make host think that clickhouse-server is localhost
echo '127.0.0.1 clickhouse-server' | sudo tee /etc/hosts > /dev/null
- name: Build cython extensions with tracing
run: CYTHON_TRACE=1 python setup.py build_ext --define CYTHON_TRACE
if: ${{ !contains(matrix.python-version, 'pypy') }}
- name: Install requirements
run: |
# Newer coveralls do not work with github actions.
pip install 'coveralls<4.0.0'
pip install 'cython<3.1.0'
pip install -U 'setuptools<72.2'
python testsrequire.py
python setup.py develop
# Limit each test time execution.
pip install pytest-timeout
env:
USE_NUMPY: ${{ matrix.use-numpy }}
USE_ARROW: ${{ matrix.use-arrow }}
- name: Run tests
run: coverage run -m pytest --timeout=10 -v
timeout-minutes: 5
env:
# Set initial TZ for docker exec -e "`env | grep ^TZ`"
TZ: UTC
- name: Upload coverage
run: coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: ${{ matrix.python-version }} CH=${{ matrix.clickhouse-version }} NUMPY=${{ matrix.use-numpy }} ARROW=${{ matrix.use-arrow }}
coveralls-finished:
name: Indicate completion to coveralls.io
needs: tests
runs-on: ubuntu-latest
steps:
- name: Finished
uses: coverallsapp/github-action@v2.3.4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
valgrind:
name: Valgrind check
needs: tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
architecture: x64
- name: Install valgrind
run: sudo apt-get update && sudo apt-get install -y valgrind
# - name: Login to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Start ClickHouse server and client containers
run: |
if [[ "21.7" = "`echo -e "21.7\n$CLICKHOUSE_VERSION" | sort -V | head -n1`" ]]; then echo "ORG=clickhouse"; else echo "ORG=yandex" ; fi >> tests/.env
if [[ "21.10" = "`echo -e "21.10\n$CLICKHOUSE_VERSION" | sort -V | head -n1`" ]]; then echo "TOP_LEVEL=clickhouse"; else echo "TOP_LEVEL=yandex" ; fi >> tests/.env
docker compose -f tests/docker-compose.yml up -d
env:
CLICKHOUSE_VERSION: 20.3.7.46
- name: Setup clickhouse-client proxy for docker
run: |
# Faking clickhouse-client real communication with container via docker exec.
echo -e '#!/bin/bash\n\ndocker exec -e "`env | grep ^TZ=`" test-clickhouse-client clickhouse-client "$@"' | sudo tee /usr/local/bin/clickhouse-client > /dev/null
sudo chmod +x /usr/local/bin/clickhouse-client
# Overriding setup.cfg. Set host=clickhouse-server
sed -i 's/^host=localhost$/host=clickhouse-server/' setup.cfg
# Make host think that clickhouse-server is localhost
echo '127.0.0.1 clickhouse-server' | sudo tee /etc/hosts > /dev/null
- name: Install requirements
run: |
pip install --upgrade pip setuptools
python testsrequire.py
python setup.py develop
env:
USE_NUMPY: 1
- name: Run tests under valgrind
run: valgrind -s --error-exitcode=1 --suppressions=valgrind.supp py.test -v
env:
# Set initial TZ for docker exec -e "`env | grep ^TZ`"
TZ: UTC
USE_NUMPY: 1
PYTHONMALLOC: malloc
wheels-linux:
name: Wheels for Linux
needs: valgrind
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
architecture: x64
# - name: Login to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Install cibuildwheel
run: |
pip install --upgrade pip setuptools
pip install cython cibuildwheel==$VERSION
env:
VERSION: 3.2.1
- name: Build wheels
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: 'cp3{9,10,11,12,13,14}-* pp3{9,10,11}-*'
CIBW_ENABLE: 'pypy pypy-eol'
CIBW_BEFORE_BUILD: pip install cython
- uses: ncipollo/release-action@v1
name: Upload wheels
if: ${{ github.ref_type == 'tag' }}
with:
artifacts: "wheelhouse/*"
allowUpdates: true
draft: true
tag: Linux
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
name: Store wheels
if: ${{ github.ref_type == 'tag' }}
with:
name: dist-linux
path: wheelhouse/*.whl
wheels-macos:
name: Wheels for OS X
needs: valgrind
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
architecture: x64
# - name: Login to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Install cibuildwheel
run: |
pip install --upgrade pip setuptools
pip install cython cibuildwheel==$VERSION
env:
VERSION: 3.2.1
- name: Build wheels
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: 'cp3{9,10,11,12,13,14}-* pp3{9,10,11}-*'
CIBW_ENABLE: 'pypy pypy-eol'
CIBW_BEFORE_BUILD: pip install cython
CIBW_ARCHS_MACOS: x86_64 arm64
- uses: ncipollo/release-action@v1
name: Upload wheels
if: ${{ github.ref_type == 'tag' }}
with:
artifacts: "wheelhouse/*"
allowUpdates: true
draft: true
tag: OS X
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
name: Store wheels
if: ${{ github.ref_type == 'tag' }}
with:
name: dist-macos
path: wheelhouse/*.whl
wheels-windows:
name: Wheels for Windows
needs: valgrind
runs-on: windows-2022
steps:
- name: Set git to use repo line breaks
run: |
git config --global core.autocrlf false
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
architecture: x64
# - name: Login to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Install cibuildwheel
run: |
pip install cibuildwheel==$env:VERSION
env:
VERSION: 3.2.1
- name: Build wheels
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: 'cp3{9,10,11,12,13,14}-* pp3{9,10,11}-*'
CIBW_ENABLE: 'pypy pypy-eol'
CIBW_BEFORE_BUILD: pip install cython
- uses: ncipollo/release-action@v1
name: Upload wheels
if: ${{ github.ref_type == 'tag' }}
with:
artifacts: "wheelhouse/*"
allowUpdates: true
draft: true
tag: Windows
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
name: Store wheels
if: ${{ github.ref_type == 'tag' }}
with:
name: dist-windows
path: wheelhouse/*.whl
wheels-linux-non-x86:
name: Wheels for Linux non-x86
needs: valgrind
runs-on: ubuntu-22.04
strategy:
matrix:
arch:
- aarch64
- ppc64le
- s390x
steps:
- uses: actions/checkout@v4
# - name: Login to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
architecture: x64
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3.2.0
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Install cibuildwheel
run: |
pip install --upgrade pip setuptools
pip install cibuildwheel==$VERSION
env:
VERSION: 3.2.1
- name: Build wheels
run: cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: 'cp3{9,10,11,12,13,14}-* pp3{9,10,11}-*'
CIBW_ENABLE: 'pypy pypy-eol'
CIBW_BEFORE_BUILD: pip install cython
CIBW_ARCHS: ${{ matrix.arch }}
- uses: ncipollo/release-action@v1
name: Upload wheels
if: ${{ github.ref_type == 'tag' }}
with:
artifacts: "wheelhouse/*"
allowUpdates: true
draft: true
tag: Linux non-x86
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
name: Store wheels
if: ${{ github.ref_type == 'tag' }}
with:
name: dist-linux-${{ matrix.arch }}
path: wheelhouse/*.whl
sdist:
name: Source distribution
needs: valgrind
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Build sdist
run: |
pip install --upgrade pip build
python -m build --sdist
- uses: actions/upload-artifact@v4
name: Store sdist
if: ${{ github.ref_type == 'tag' }}
with:
name: dist-sdist
path: dist/*.tar.gz
publish-pypi:
name: Publish to PyPI
if: ${{ github.ref_type == 'tag' }}
needs:
- sdist
- wheels-linux
- wheels-macos
- wheels-windows
- wheels-linux-non-x86
runs-on: ubuntu-22.04
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: dist-*
merge-multiple: true
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1