Skip to content

Commit

Permalink
Connection flow improved
Browse files Browse the repository at this point in the history
* Added check for is_closing to protocol.pyx so _on_connection_lost is called exactly once
* Removed IDLE state. Now connection starts from DISCONNECTED state
* Simplified disconnect and reconnect process.
* Added Lock for disonnect() process
* Added `is_fully_connected` property proxy to Protocol's one
* Added ContextManager protocol for Connection class
* Fixed reconnect issues (closes #11)
  • Loading branch information
igorcoding committed Aug 13, 2018
1 parent b4c2118 commit 64707c0
Show file tree
Hide file tree
Showing 14 changed files with 547 additions and 253 deletions.
3 changes: 2 additions & 1 deletion .ci/travis-before-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
echo "deb-src https://packagecloud.io/tarantool/${TARANTOOL_VERSION}/ubuntu/ $release main" | sudo tee -a /etc/apt/sources.list.d/tarantool_${TARANTOOL_VERSION}.list
sudo apt-get -qq update
sudo apt-get -y install tarantool
sudo tarantoolctl stop example || exit 0
tarantool -V || exit 1
sudo tarantoolctl stop example
sudo apt-get install pandoc libssl-dev openssl
elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
brew update
Expand Down
49 changes: 49 additions & 0 deletions .ci/travis-build-wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

set -e -x


if [[ -z "${TRAVIS_TAG}" || "${BUILD}" != *wheels* ]]; then
# Not a release
exit 0
fi

if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
PYENV_ROOT="$HOME/.pyenv"
PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
fi

if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
for pyver in ${RELEASE_PYTHON_VERSIONS}; do
ML_PYTHON_VERSION=$(python3 -c \
"print('cp{maj}{min}-cp{maj}{min}m'.format( \
maj='${pyver}'.split('.')[0], \
min='${pyver}'.split('.')[1]))")

for arch in x86_64 i686; do
ML_IMAGE="quay.io/pypa/manylinux1_${arch}"
docker pull "${ML_IMAGE}"
docker run --rm \
-v "${_root}":/io \
-e "PYMODULE=${PYMODULE}" \
-e "PYTHON_VERSION=${ML_PYTHON_VERSION}" \
-e "ASYNCPG_VERSION=${PACKAGE_VERSION}" \
"${ML_IMAGE}" /io/.ci/build-manylinux-wheels.sh

_upload_wheels
done
done

elif [ "${TRAVIS_OS_NAME}" == "osx" ]; then
make clean
python setup.py bdist_wheel

pip install ${PYMODULE}[test] -f "file:///${_root}/dist"
make -C "${_root}" ASYNCPG_VERSION="${PACKAGE_VERSION}" testinstalled

_upload_wheels

else
echo "Cannot build on ${TRAVIS_OS_NAME}."
fi
3 changes: 1 addition & 2 deletions .ci/travis-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
eval "$(pyenv init -)"
fi

pip install --upgrade pip wheel
pip install --upgrade setuptools
pip install --upgrade pip wheel setuptools
pip install -r requirements.txt
pip install coveralls
pip install -e .
84 changes: 54 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,12 @@ env:
global:
- ENCRYPTION_LABEL: "8db6dbddd29a"
- COMMIT_AUTHOR_EMAIL: "igorcoding@gmail.com"
- RELEASE_PYTHON_VERSIONS: "3.5 3.6 3.7"

matrix:
fast_finish: true
include:

# osx
- os: osx
language: generic
env: BUILD=tests PYTHON_VERSION=3.6.0 TARANTOOL_VERSION=1_9

- os: osx
language: generic
env: BUILD=tests PYTHON_VERSION=3.6.0 TARANTOOL_VERSION=1_9

- os: osx
language: generic
env: BUILD=tests PYTHON_VERSION=3.7.0 TARANTOOL_VERSION=1_9

- os: osx
language: generic
env: BUILD=tests PYTHON_VERSION=3.7.0 TARANTOOL_VERSION=1_9

# precise python3.5 Tarantool 1.6
- os: linux
dist: precise
sudo: required
language: python
python: '3.5'
env: BUILD=quicktests TARANTOOL_VERSION=1_6

# trusty python3.5 Tarantool 1.6
- os: linux
dist: trusty
Expand All @@ -47,7 +23,7 @@ matrix:
sudo: required
language: python
python: '3.5'
env: BUILD=tests TARANTOOL_VERSION=1_7
env: BUILD=quicktests TARANTOOL_VERSION=1_7

# trusty python3.5 Tarantool 1.9
- os: linux
Expand All @@ -57,6 +33,22 @@ matrix:
python: '3.5'
env: BUILD=tests TARANTOOL_VERSION=1_9

# trusty python3.6 Tarantool 1.6
- os: linux
dist: trusty
sudo: required
language: python
python: '3.6'
env: BUILD=quicktests TARANTOOL_VERSION=1_6

# trusty python3.6 Tarantool 1.7
- os: linux
dist: trusty
sudo: required
language: python
python: '3.6'
env: BUILD=quicktests TARANTOOL_VERSION=1_7

# trusty python3.6 Tarantool 1.9
- os: linux
dist: trusty
Expand All @@ -65,6 +57,22 @@ matrix:
python: '3.6'
env: BUILD=tests TARANTOOL_VERSION=1_9

# xenial python3.7 Tarantool 1.6
- os: linux
dist: xenial
sudo: required
language: python
python: '3.7'
env: BUILD=quicktests TARANTOOL_VERSION=1_6

# xenial python3.7 Tarantool 1.7
- os: linux
dist: xenial
sudo: required
language: python
python: '3.7'
env: BUILD=quicktests TARANTOOL_VERSION=1_7

# xenial python3.7 Tarantool 1.9
- os: linux
dist: xenial
Expand All @@ -73,13 +81,28 @@ matrix:
python: '3.7'
env: BUILD=tests TARANTOOL_VERSION=1_9

# trusty python3.6 Tarantool 1.9 + deploy
# deploy with Tarantool 1.9 and all pythons
- os: linux
dist: trusty
dist: xenial
sudo: required
language: python
python: '3.6'
env: BUILD=tests,docs,coverage,release TARANTOOL_VERSION=1_9
python: '3.7'
env: BUILD=tests,wheel,docs,coverage,release TARANTOOL_VERSION=1_9
services:
- docker

# osx
- os: osx
language: generic
env: BUILD=tests,wheel PYTHON_VERSION=3.5.5 TARANTOOL_VERSION=1_9

- os: osx
language: generic
env: BUILD=tests,wheel PYTHON_VERSION=3.6.0 TARANTOOL_VERSION=1_9

- os: osx
language: generic
env: BUILD=tests,wheel PYTHON_VERSION=3.7.0 TARANTOOL_VERSION=1_9

cache:
- pip
Expand All @@ -93,6 +116,7 @@ install:
script:
- ".ci/travis-tests.sh"
- ".ci/travis-build-docs.sh"
#- ".ci/travis-build-wheel.sh"

after_success:
- if [[ "${BUILD}" == *coverage* ]]; then coveralls; fi
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
v0.2.0

Changes:
* Improved and simplified connect/reconnect process
* Added ContextManager async with protocol for Connection
* Added `is_fully_connected` property to Connection
* Added disconnect Lock

Bugs Fixed:
* Auto reconnect misbehaved on double on_connection_lost trigger (#11)

v0.1.13

Changes:
Expand Down
2 changes: 1 addition & 1 deletion asynctnt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .connection import Connection, connect
from .iproto.protocol import Iterator, Response

__version__ = '0.1.13'
__version__ = '0.2.0'
Loading

0 comments on commit 64707c0

Please sign in to comment.