mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-05 15:35:06 +00:00
refactor(downloader): make dl.result the one writer of the speed limit and drop speed_limit_locked
This commit is contained in:
@@ -7,7 +7,7 @@ from types import SimpleNamespace
|
||||
import pytest
|
||||
|
||||
from unshackle.core.constants import DOWNLOAD_CANCELLED
|
||||
from unshackle.core.downloaders.requests import TokenBucket, format_speed, parse_speed_limit, set_speed_limit
|
||||
from unshackle.core.downloaders.requests import TokenBucket, format_speed, parse_speed_limit
|
||||
|
||||
requests_downloader = importlib.import_module("unshackle.core.downloaders.requests")
|
||||
|
||||
@@ -119,15 +119,6 @@ def test_bucket_chunk_larger_than_capacity_does_not_deadlock(monkeypatch):
|
||||
assert 1.0 < waits[0] < 2.0
|
||||
|
||||
|
||||
def test_locked_limit_ignores_unlocked_calls():
|
||||
"""serve's global_speed_limit must survive the per-job set in dl.result()."""
|
||||
set_speed_limit(5_000_000, lock=True)
|
||||
set_speed_limit(None)
|
||||
set_speed_limit(1_000_000)
|
||||
limiter = requests_downloader.speed_limiter
|
||||
assert limiter is not None and limiter.rate == 5_000_000
|
||||
|
||||
|
||||
def test_bucket_wait_aborts_on_cancellation():
|
||||
"""Debt sleeps grow with thread count; cancelling must not wait them out."""
|
||||
bucket = TokenBucket(1_000)
|
||||
|
||||
Reference in New Issue
Block a user