Skip to content

Commit e87668e

Browse files
author
olegm
committed
py38+: explicit loop argument warnings fixed; requirements, scripts and github action updated
1 parent 001f9c1 commit e87668e

File tree

8 files changed

+33
-20
lines changed

8 files changed

+33
-20
lines changed

.github/workflows/tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
test:
1212
name: run all tests
13-
runs-on: ubuntu-18.04
13+
runs-on: ubuntu-20.04
1414
strategy:
1515
matrix:
1616
python-version: [3.5, 3.6, 3.7, 3.8, 'pypy3']
@@ -22,6 +22,6 @@ jobs:
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424
- name: pip-requirements
25-
run: pip install --upgrade pytest pytest-asyncio async-timeout
25+
run: pip install --upgrade -r reqs-test.txt
2626
- name: run-test
27-
run: pytest --continue-on-collection-errors ./tests
27+
run: pytest -sv --continue-on-collection-errors ./tests

asyncio_pool/base_pool.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ def __init__(self, size=1024, *, loop=None):
2424
futures, not "native" ones, returned by `pool.create_task` or used for
2525
`await`. Read more about this in readme and docstrings below.
2626
'''
27-
self.loop = loop or aio.get_event_loop()
27+
28+
self.loop = loop or _get_loop()
2829

2930
self.size = size
3031
self._executed = 0
3132
self._joined = set()
3233
self._waiting = {} # future -> task
3334
self._active = {} # future -> task
34-
self.semaphore = aio.Semaphore(value=self.size, loop=self.loop)
35+
self.semaphore = aio.Semaphore(value=self.size)
3536

3637
async def __aenter__(self):
3738
return self
@@ -276,3 +277,13 @@ async def cancel(self, *futures, get_result=getres.flat):
276277
await aio.wait(tasks) # let them actually cancel
277278
# need to collect them anyway, to supress warnings
278279
return cancelled, [get_result(fut) for fut in _futures]
280+
281+
282+
def _get_loop():
283+
"""
284+
Backward compatibility w/ py<3.8
285+
"""
286+
287+
if hasattr(aio, 'get_running_loop'):
288+
return aio.get_running_loop()
289+
return aio.get_event_loop()

asyncio_pool/mx_asyncgen.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ async def itermap(self, fn, iterable, cb=None, ctx=None, *, flat=True,
3939
'''
4040
futures = self.map_n(fn, iterable, cb, ctx)
4141
generator = iterwait(futures, flat=flat, timeout=timeout,
42-
get_result=get_result, yield_when=yield_when, loop=self.loop)
42+
get_result=get_result, yield_when=yield_when)
4343
async for batch in generator:
4444
yield batch # TODO is it possible to return a generator?

reqs-dev.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
asyncio
1+
-r reqs-test.txt
2+
23
ipython
3-
pytest
4-
pytest-asyncio
5-
async-timeout
64
setuptools
75
wheel
86
twine

reqs-test.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
async-timeout
2+
pytest
3+
pytest-asyncio

run_tests.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#! /bin/sh
22

3-
## 3.5 and pypy (which is also 3.5) are disalbed because of async generators
4-
py35=python3.5
53
pypy3=pypy3
4+
py35=python3.5
65
py36=python3.6
76
py37=python3.7
7+
py38=python3.8
8+
py39=python3.9
89

9-
default_env=$py36
10+
default_env=$py37
1011

1112

1213
todo=${@:-"./tests"}
1314

14-
for py in $py35 $py36 $py37 $pypy3
15+
for py in $py35 $py36 $py37 $py38 $py39 $pypy3
1516
do
1617
echo ""
1718
if [ -x "$(command -v $py)" ]; then

setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
setuptools.setup(
1717
name='asyncio_pool',
18-
version='0.4.1',
18+
version='0.5.0',
1919
author='gistart',
2020
author_email='[email protected]',
2121
description='Pool of asyncio coroutines with familiar interface',
@@ -33,7 +33,6 @@
3333
"Programming Language :: Python :: 3.7",
3434
"License :: OSI Approved :: MIT License",
3535
"Operating System :: OS Independent",
36-
"Development Status :: 4 - Beta",
3736
"Framework :: AsyncIO",
3837
)
3938
)

setup_dev.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#! /bin/sh
22

3+
pypy3=pypy3
34
py35=python3.5
4-
pypy3=pypy3 # also 3.5 currently
55
py36=python3.6
66
py37=python3.7
7-
#pypy3=/opt/pypy3/pypy3/bin/pypy3
7+
py38=python3.8
8+
py39=python3.9
89

9-
default_env=$py36
10+
default_env=$py37
1011

1112

12-
for py in $py35 $pypy3 $py36 $py37
13+
for py in $pypy3 $py35 $py36 $py37 $py38 $py39
1314
do
1415
if [ -x "$(command -v $py)" ]; then
1516
pyname="$(basename $py)"

0 commit comments

Comments
 (0)