From 6a555ec98bd44162d2b95067a72709e74f21aa62 Mon Sep 17 00:00:00 2001 From: Pradip Caulagi Date: Sun, 27 Jan 2019 21:26:57 +0100 Subject: [PATCH 1/3] Run tests for python 3.7 in CI and fix failing tests --- .travis.yml | 13 +++++++++++++ aiomysql/sa/result.py | 2 +- aiomysql/utils.py | 19 ++++++++++++++++--- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d5c48828..d07f649e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: python python: - 3.5.3 - 3.6 + - 3.7 env: matrix: @@ -30,6 +31,18 @@ matrix: env: PYTHONASYNCIODEBUG= addons: mysql: 5.7 + - python: 3.7 + dist: xenial + sudo: true + env: PYTHONASYNCIODEBUG=1 + addons: + mariadb: 10.1 + - python: 3.7 + dist: xenial + sudo: true + env: PYTHONASYNCIODEBUG=1 + addons: + mysql: 5.7 before_script: diff --git a/aiomysql/sa/result.py b/aiomysql/sa/result.py index faeaff56..f34d3ff9 100644 --- a/aiomysql/sa/result.py +++ b/aiomysql/sa/result.py @@ -447,7 +447,7 @@ async def scalar(self): else: return None - async def __aiter__(self): + def __aiter__(self): return self async def __anext__(self): diff --git a/aiomysql/utils.py b/aiomysql/utils.py index 9b74b9df..7fbac46c 100644 --- a/aiomysql/utils.py +++ b/aiomysql/utils.py @@ -1,3 +1,5 @@ +import asyncio + from collections.abc import Coroutine @@ -70,9 +72,20 @@ async def __aexit__(self, exc_type, exc, tb): class _SAConnectionContextManager(_ContextManager): - async def __aiter__(self): - result = await self._coro - return result + def __aiter__(self): + return self + + @asyncio.coroutine + def __anext__(self): + if self._obj is None: + self._obj = yield from self._coro + + try: + return (yield from self._obj.__anext__()) + except StopAsyncIteration: + self._obj.close() + self._obj = None + raise class _TransactionContextManager(_ContextManager): From b7f49701861412c7e18d84c4826bc4715ab43f1a Mon Sep 17 00:00:00 2001 From: Pradip Caulagi Date: Sun, 27 Jan 2019 21:48:37 +0100 Subject: [PATCH 2/3] Python 3.7 requires xenial for openssl support --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d07f649e..e59958b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +dist: xenial +sudo: true language: python python: @@ -32,14 +34,10 @@ matrix: addons: mysql: 5.7 - python: 3.7 - dist: xenial - sudo: true env: PYTHONASYNCIODEBUG=1 addons: mariadb: 10.1 - python: 3.7 - dist: xenial - sudo: true env: PYTHONASYNCIODEBUG=1 addons: mysql: 5.7 From b926d9e01a17151a2c9aac9c8f200d9b494a3d7a Mon Sep 17 00:00:00 2001 From: Pradip Caulagi Date: Mon, 28 Jan 2019 15:06:17 +0100 Subject: [PATCH 3/3] Trigger build --- aiomysql/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/aiomysql/utils.py b/aiomysql/utils.py index 7fbac46c..e55c19a0 100644 --- a/aiomysql/utils.py +++ b/aiomysql/utils.py @@ -1,5 +1,4 @@ import asyncio - from collections.abc import Coroutine