added optional semphore
This commit is contained in:
1 parent
0cfcca01bb
commit
4b63a2d39c
2 files changed
+33
-7
No files matched your search
@@ -82,3 +82,26 @@ def test_single_call_respects_its_semaphore():
|
||||
|
||||
asyncio.run(run())
|
||||
assert state["peak"] <= limit, f"peak {state['peak']} over limit {limit}"
|
||||
|
||||
|
||||
def test_omitted_semaphore_runs_unbounded():
|
||||
"""Omitting the semaphore lets all pages fan out concurrently.
|
||||
|
||||
With no semaphore the only bound is the page count; pages 2..10 (nine pages)
|
||||
should all be in flight at once, so peak concurrency reaches nine.
|
||||
"""
|
||||
|
||||
state = {"live": 0, "peak": 0}
|
||||
func = _make_tracking_func(state)
|
||||
|
||||
async def run():
|
||||
await execute_pagination(
|
||||
"cat",
|
||||
total_products=300,
|
||||
products_per_page=30,
|
||||
func=func,
|
||||
session=None,
|
||||
)
|
||||
|
||||
asyncio.run(run())
|
||||
assert state["peak"] == 9, f"expected all 9 pages concurrent, got {state['peak']}"
|
||||
Reference in new issue
Block a user