Skip to content

Commit

Permalink
fix: optimize tests for at least 2 workers
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Kryukov committed Aug 4, 2023
1 parent ed17e57 commit 7640b77
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ jobs:
run: |
python3 -m pip install --upgrade pip setuptools wheel twine
python3 -m pip install -r requirements.txt
- name: Install module
run: |
python3 setup.py install
- name: Test with coverage and pytest
run: |
python3 -m pytest tests/
make test
- name: Generate distribution archives
run: |
python3 setup.py sdist bdist_wheel
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![PyPI version](https://badge.fury.io/py/bounded-pool.svg)](https://badge.fury.io/py/bounded-pool)

Simplistic and universal bounded pool executer that allows to process N tasks
Simplistic and universal bounded pool executor that allows to process N tasks
as the same time while limiting size of the queue. Tasks can be functions or
coroutines. Under the hood `bounded_pool` uses threads or processes, depending
on used class. Refer to `tests/test_basic.py` for details.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ flake8-quotes~=3.3.1
flake8~=4.0.1
pytest-cov~=4.1.0
pytest-xdist~=3.3.1
pytest~=6.2.5
pytest~=7.4.0
10 changes: 5 additions & 5 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
@pytest.mark.anyio
async def test_asyncio_executor_sleeps():
async with aassert_takes(less=1.5):
async with BoundedAsyncioPoolExecutor(4) as pool:
async with BoundedAsyncioPoolExecutor(2) as pool:
async with aassert_takes(less=0.5):
for _ in range(4):
for _ in range(2):
await pool.submit(asyncio.sleep, 1)

assert not pool._tasks
Expand All @@ -34,13 +34,13 @@ async def test_asyncio_executor_sleeps():
@pytest.mark.parametrize('cls', [BoundedThreadPoolExecutor, BoundedProcessPoolExecutor])
def test_sync_executor_sleeps(cls):
with assert_takes(less=1.5):
with cls(4) as pool:
with cls(2) as pool:
with assert_takes(less=0.5):
for _ in range(4):
for _ in range(2):
pool.submit(time.sleep, 1)

with assert_takes(more=3.5):
with cls(1) as pool:
with assert_takes(more=3):
for _ in range(4):
for _ in range(2):
pool.submit(time.sleep, 1)

0 comments on commit 7640b77

Please sign in to comment.