Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
language: python
sudo: false
dist: trusty
dist: focal

matrix:
include:
# These are quick and often catch errors, so list them first
- python: 3.6
- python: 3.8
env: CHECK_DOCS=1
- python: 3.6
- python: 3.8
env: CHECK_FORMATTING=1
# The pypy tests are slow, so list them early
- python: pypy3.5
# The pypy tests are slow, so we list them first
- python: pypy3.6-7.2.0
dist: bionic
- language: generic
env: PYPY_NIGHTLY_BRANCH=py3.6
# Uncomment if you want to test on pypy nightly:
# - language: generic
# env: USE_PYPY_NIGHTLY=1
- python: 3.5.0
- python: 3.5.2
- python: 3.6
- python: 3.6-dev
# As of 2018-07-05, Travis's 3.7 and 3.8 builds only work if you
# use dist: xenial AND sudo: required
# See: https://github.com/python-trio/trio/pull/556#issuecomment-402879391
- python: 3.7
dist: xenial
sudo: required
- python: 3.7-dev
- python: 3.8-dev
dist: xenial
sudo: required
- python: 3.9-dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, the reason Trio's config is like that is because most tests happen in GitHub Actions. But since Travis has good support for dev versions and PyPy, Trio continues to test those in Travis.

In trimeter's case, it would be better to keep both 3.x and 3.x-dev for each supported version

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. I might try reworking QTrio's GHA configuration first. There's a fair bit of repetition in the way it is now that isn't obviously useful in my head vs. the one big matrix I made over in pytest-twisted for example. But maybe as I implement that in QTrio I'll find an issue, of course.


script:
- ci/travis.sh
4 changes: 4 additions & 0 deletions ci/rtd-requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# RTD is currently installing 1.5.3, which has a bug in :lineno-match:
sphinx >= 1.6.1
sphinx_rtd_theme
sphinxcontrib-trio
39 changes: 35 additions & 4 deletions ci/rtd-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
# RTD is currently installing 1.5.3, which has a bug in :lineno-match:
sphinx >= 1.6.1
sphinx_rtd_theme
sphinxcontrib-trio
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file=rtd-requirements.txt rtd-requirements.in
#
alabaster==0.7.12 # via sphinx
babel==2.8.0 # via sphinx
certifi==2020.6.20 # via requests
chardet==3.0.4 # via requests
docutils==0.16 # via sphinx
idna==2.10 # via requests
imagesize==1.2.0 # via sphinx
jinja2==2.11.2 # via sphinx
markupsafe==1.1.1 # via jinja2
packaging==20.4 # via sphinx
pygments==2.6.1 # via sphinx
pyparsing==2.4.7 # via packaging
pytz==2020.1 # via babel
requests==2.24.0 # via sphinx
six==1.15.0 # via packaging
snowballstemmer==2.0.0 # via sphinx
sphinx-rtd-theme==0.5.0 # via -r rtd-requirements.in
sphinx==3.2.1 # via -r rtd-requirements.in, sphinx-rtd-theme, sphinxcontrib-trio
sphinxcontrib-applehelp==1.0.2 # via sphinx
sphinxcontrib-devhelp==1.0.2 # via sphinx
sphinxcontrib-htmlhelp==1.0.3 # via sphinx
sphinxcontrib-jsmath==1.0.1 # via sphinx
sphinxcontrib-qthelp==1.0.3 # via sphinx
sphinxcontrib-serializinghtml==1.1.4 # via sphinx
sphinxcontrib-trio==1.1.2 # via -r rtd-requirements.in
urllib3==1.25.10 # via requests

# The following packages are considered to be unsafe in a requirements file:
# setuptools
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
"attrs",
],
keywords=[
"async", "scheduler", "trio",
"async",
"scheduler",
"trio",
],
python_requires=">=3.5",
python_requires=">=3.6",
classifiers=[
"License :: OSI Approved :: MIT License",
"License :: OSI Approved :: Apache Software License",
Expand Down
2 changes: 2 additions & 0 deletions test-requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest
pytest-cov
20 changes: 18 additions & 2 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
pytest
pytest-cov
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file=test-requirements.txt test-requirements.in
#
attrs==20.1.0 # via pytest
coverage==5.2.1 # via pytest-cov
iniconfig==1.0.1 # via pytest
more-itertools==8.5.0 # via pytest
packaging==20.4 # via pytest
pluggy==0.13.1 # via pytest
py==1.9.0 # via pytest
pyparsing==2.4.7 # via packaging
pytest-cov==2.10.1 # via -r test-requirements.in
pytest==6.0.1 # via -r test-requirements.in, pytest-cov
six==1.15.0 # via packaging
toml==0.10.1 # via pytest
12 changes: 6 additions & 6 deletions trimeter/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def new_state(self):
class MaxState:
def __init__(self, max_meter):
self.sem = trio.Semaphore(
initial_value=max_meter.max_at_once, max_value=max_meter.max_at_once
initial_value=max_meter.max_at_once,
max_value=max_meter.max_at_once
)

async def wait_task_can_start(self):
Expand All @@ -73,7 +74,9 @@ def notify_task_finished(self):
@attr.s(frozen=True)
class TokenBucketMeter:
max_per_second = attr.ib(converter=float, validator=_check_positive)
max_burst = attr.ib(default=1, converter=operator.index, validator=_check_positive)
max_burst = attr.ib(
default=1, converter=operator.index, validator=_check_positive
)

def __attrs_post_init__(self):
_check_positive(self, "max_per_second", self.max_per_second)
Expand Down Expand Up @@ -121,9 +124,7 @@ def notify_task_finished(self):


# XX should we have a special-case to allow KeyboardInterrupt to pass through?
async def _worker(
async_fn, value, index, config
):
async def _worker(async_fn, value, index, config):
if config.capture_outcome:
result = await outcome.acapture(async_fn, value)
else:
Expand Down Expand Up @@ -203,7 +204,6 @@ async def run_on_each(
await send_to.aclose()



@asynccontextmanager
@async_generator
async def amap(
Expand Down
1 change: 1 addition & 0 deletions trimeter/_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
from trio.testing import MockClock, trio_test


@pytest.fixture
def mock_clock():
return MockClock()
Expand Down
13 changes: 8 additions & 5 deletions trimeter/_tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import trio
from trimeter import run_on_each, amap, run_all


# Just the most basic smoke test of the three functions
async def test_basics():
ran_on = []
Expand All @@ -20,9 +21,11 @@ async def afn(value):
results.append(result)
assert sorted(results) == [2, 3, 4]

results = await run_all([
partial(afn, 10),
partial(afn, 11),
partial(afn, 12),
])
results = await run_all(
[
partial(afn, 10),
partial(afn, 11),
partial(afn, 12),
]
)
assert results == [11, 12, 13]