Skip to content

Commit 5b20a8a

Browse files
authored
Drop old python (#288)
* cleanup * flake8 * more cleanup * tweak travis config * move tests
1 parent 3041c67 commit 5b20a8a

16 files changed

+23
-54
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: python
22

33
python:
4-
- 3.5
4+
- 3.5.3
55
- 3.6
66

77
env:

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ FLAGS=
44

55

66
flake:
7-
exclude=$$(python -c "import sys;sys.stdout.write('--exclude tests/pep492') if sys.version_info[:3] < (3, 5, 0) else None"); \
8-
flake8 aiomysql tests $$exclude
7+
flake8 aiomysql tests examples
98

109
test: flake
1110
py.test -s $(FLAGS) ./tests/

README.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ for aiopg_ user.:
137137
Requirements
138138
------------
139139

140-
* Python_ 3.3+
141-
* asyncio_ or Python_ 3.4+
140+
* Python_ 3.5.3+
142141
* PyMySQL_
143142

144143

aiomysql/connection.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141

4242
# from aiomysql.utils import _convert_to_str
4343
from .cursors import Cursor
44-
from .utils import (_ConnectionContextManager, _ContextManager,
45-
create_future)
44+
from .utils import _ConnectionContextManager, _ContextManager
4645
# from .log import logger
4746

4847
DEFAULT_USER = getpass.getuser()
@@ -384,7 +383,7 @@ def cursor(self, cursor=None):
384383
cur = cursor(self, self._echo)
385384
else:
386385
cur = self.cursorclass(self, self._echo)
387-
fut = create_future(self._loop)
386+
fut = self._loop.create_future()
388387
fut.set_result(cur)
389388
return _ContextManager(fut)
390389

aiomysql/cursors.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
NotSupportedError, ProgrammingError)
88

99
from .log import logger
10-
from .utils import create_future
1110

1211

1312
# https://github.com/PyMySQL/PyMySQL/blob/master/pymysql/cursors.py#L11-L18
@@ -362,15 +361,15 @@ async def callproc(self, procname, args=()):
362361
def fetchone(self):
363362
"""Fetch the next row """
364363
self._check_executed()
365-
fut = create_future(self._loop)
364+
fut = self._loop.create_future()
366365

367366
if self._rows is None or self._rownumber >= len(self._rows):
368367
fut.set_result(None)
369368
return fut
370369
result = self._rows[self._rownumber]
371370
self._rownumber += 1
372371

373-
fut = create_future(self._loop)
372+
fut = self._loop.create_future()
374373
fut.set_result(result)
375374
return fut
376375

@@ -386,7 +385,7 @@ def fetchmany(self, size=None):
386385
:returns: ``list`` of fetched rows
387386
"""
388387
self._check_executed()
389-
fut = create_future(self._loop)
388+
fut = self._loop.create_future()
390389
if self._rows is None:
391390
fut.set_result([])
392391
return fut
@@ -403,7 +402,7 @@ def fetchall(self):
403402
:returns: ``list`` of fetched rows
404403
"""
405404
self._check_executed()
406-
fut = create_future(self._loop)
405+
fut = self._loop.create_future()
407406
if self._rows is None:
408407
fut.set_result([])
409408
return fut
@@ -443,7 +442,7 @@ def scroll(self, value, mode='relative'):
443442
raise IndexError("out of range")
444443
self._rownumber = r
445444

446-
fut = create_future(self._loop)
445+
fut = self._loop.create_future()
447446
fut.set_result(None)
448447
return fut
449448

aiomysql/pool.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from .connection import connect
99
from .utils import (_PoolContextManager, _PoolConnectionContextManager,
10-
_PoolAcquireContextManager, create_future, create_task)
10+
_PoolAcquireContextManager)
1111

1212

1313
def create_pool(minsize=1, maxsize=10, echo=False, pool_recycle=-1,
@@ -194,7 +194,7 @@ def release(self, conn):
194194
195195
This is **NOT** a coroutine.
196196
"""
197-
fut = create_future(self._loop)
197+
fut = self._loop.create_future()
198198
fut.set_result(None)
199199

200200
if conn in self._terminated:
@@ -212,7 +212,7 @@ def release(self, conn):
212212
conn.close()
213213
else:
214214
self._free.append(conn)
215-
fut = create_task(self._wakeup(), self._loop)
215+
fut = self._loop.create_task(self._wakeup())
216216
return fut
217217

218218
def get(self):

aiomysql/sa/result.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from sqlalchemy.sql import expression, sqltypes
88

99
from . import exc
10-
from ..utils import create_task
1110

1211

1312
async def create_result_proxy(connection, cursor, dialect):
@@ -239,7 +238,7 @@ async def _prepare(self):
239238
self._metadata = ResultMetaData(self, cursor.description)
240239

241240
def callback(wr):
242-
create_task(cursor.close(), loop)
241+
loop.create_task(cursor.close())
243242
self._weak = weakref.ref(self, callback)
244243
else:
245244
self._metadata = None

aiomysql/utils.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,6 @@
1-
import asyncio
2-
31
from collections.abc import Coroutine
42

53

6-
def create_future(loop):
7-
"""Compatibility wrapper for the loop.create_future() call introduced in
8-
3.5.2."""
9-
if hasattr(loop, 'create_future'):
10-
return loop.create_future()
11-
else:
12-
return asyncio.Future(loop=loop)
13-
14-
15-
def create_task(coro, loop):
16-
"""Compatibility wrapper for the loop.create_task() call introduced in
17-
3.4.2."""
18-
if hasattr(loop, 'create_task'):
19-
return loop.create_task(coro)
20-
else:
21-
return asyncio.Task(coro, loop=loop)
22-
23-
244
class _ContextManager(Coroutine):
255

266
__slots__ = ('_coro', '_obj')
@@ -169,9 +149,3 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
169149
finally:
170150
self._pool = None
171151
self._conn = None
172-
173-
174-
try:
175-
asyncio.coroutines._COROUTINE_TYPES += (_ContextManager,)
176-
except Exception:
177-
pass

examples/example_executemany_oldstyle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ def test_example_executemany():
4040
yield from cur.close()
4141
conn.close()
4242

43+
4344
loop.run_until_complete(test_example_executemany())

examples/example_oldstyle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ def test_example():
1919
yield from cur.close()
2020
conn.close()
2121

22+
2223
loop.run_until_complete(test_example())

0 commit comments

Comments
 (0)