Skip to content

Commit

Permalink
py38+: explicit loop argument warnings fixed; requirements, scripts a…
Browse files Browse the repository at this point in the history
…nd github action updated
  • Loading branch information
olegm committed Aug 4, 2020
1 parent 001f9c1 commit e87668e
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
test:
name: run all tests
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 'pypy3']
Expand All @@ -22,6 +22,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: pip-requirements
run: pip install --upgrade pytest pytest-asyncio async-timeout
run: pip install --upgrade -r reqs-test.txt
- name: run-test
run: pytest --continue-on-collection-errors ./tests
run: pytest -sv --continue-on-collection-errors ./tests
15 changes: 13 additions & 2 deletions asyncio_pool/base_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ def __init__(self, size=1024, *, loop=None):
futures, not "native" ones, returned by `pool.create_task` or used for
`await`. Read more about this in readme and docstrings below.
'''
self.loop = loop or aio.get_event_loop()

self.loop = loop or _get_loop()

self.size = size
self._executed = 0
self._joined = set()
self._waiting = {} # future -> task
self._active = {} # future -> task
self.semaphore = aio.Semaphore(value=self.size, loop=self.loop)
self.semaphore = aio.Semaphore(value=self.size)

async def __aenter__(self):
return self
Expand Down Expand Up @@ -276,3 +277,13 @@ async def cancel(self, *futures, get_result=getres.flat):
await aio.wait(tasks) # let them actually cancel
# need to collect them anyway, to supress warnings
return cancelled, [get_result(fut) for fut in _futures]


def _get_loop():
"""
Backward compatibility w/ py<3.8
"""

if hasattr(aio, 'get_running_loop'):
return aio.get_running_loop()
return aio.get_event_loop()
2 changes: 1 addition & 1 deletion asyncio_pool/mx_asyncgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ async def itermap(self, fn, iterable, cb=None, ctx=None, *, flat=True,
'''
futures = self.map_n(fn, iterable, cb, ctx)
generator = iterwait(futures, flat=flat, timeout=timeout,
get_result=get_result, yield_when=yield_when, loop=self.loop)
get_result=get_result, yield_when=yield_when)
async for batch in generator:
yield batch # TODO is it possible to return a generator?
6 changes: 2 additions & 4 deletions reqs-dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
asyncio
-r reqs-test.txt

ipython
pytest
pytest-asyncio
async-timeout
setuptools
wheel
twine
3 changes: 3 additions & 0 deletions reqs-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
async-timeout
pytest
pytest-asyncio
9 changes: 5 additions & 4 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#! /bin/sh

## 3.5 and pypy (which is also 3.5) are disalbed because of async generators
py35=python3.5
pypy3=pypy3
py35=python3.5
py36=python3.6
py37=python3.7
py38=python3.8
py39=python3.9

default_env=$py36
default_env=$py37


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

for py in $py35 $py36 $py37 $pypy3
for py in $py35 $py36 $py37 $py38 $py39 $pypy3
do
echo ""
if [ -x "$(command -v $py)" ]; then
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setuptools.setup(
name='asyncio_pool',
version='0.4.1',
version='0.5.0',
author='gistart',
author_email='gistart@yandex.ru',
description='Pool of asyncio coroutines with familiar interface',
Expand All @@ -33,7 +33,6 @@
"Programming Language :: Python :: 3.7",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 4 - Beta",
"Framework :: AsyncIO",
)
)
9 changes: 5 additions & 4 deletions setup_dev.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#! /bin/sh

pypy3=pypy3
py35=python3.5
pypy3=pypy3 # also 3.5 currently
py36=python3.6
py37=python3.7
#pypy3=/opt/pypy3/pypy3/bin/pypy3
py38=python3.8
py39=python3.9

default_env=$py36
default_env=$py37


for py in $py35 $pypy3 $py36 $py37
for py in $pypy3 $py35 $py36 $py37 $py38 $py39
do
if [ -x "$(command -v $py)" ]; then
pyname="$(basename $py)"
Expand Down

0 comments on commit e87668e

Please sign in to comment.