fix(dl): stop a failed mux with one line that names the free space

This commit is contained in:
imSp4rky
2026-11-28 15:26:38 -07:00
parent 418d69b1ec
commit 74856d2ddb
7 changed files with 145 additions and 38 deletions
+20 -1
View File
@@ -28,7 +28,10 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import pytest
from requests import Session
from tests.downloaders.test_outage_budget import _FullDisk
from unshackle.core.api.errors import categorize_exception
from unshackle.core.constants import DownloadCancelled
from unshackle.core.remote_protocol import APIErrorCode
from unshackle.core.utils.sslciphers import SSLCiphers
dl = importlib.import_module("unshackle.core.downloaders.requests")
@@ -103,6 +106,11 @@ def die_without_result(queue, kwargs):
os._exit(3)
def full_disk_worker(queue, kwargs):
dl.open = _FullDisk
dl.mp_worker(queue, kwargs)
def run_mp(urls, tmp_path):
for _ in dl.download_multiprocess(
urls=urls,
@@ -148,9 +156,20 @@ def test_multiprocess_child_crash_raises(server, tmp_path):
# any retry loop), so the child sends __mp_error__ fast; the sibling downloads normally.
good = {"url": url(server, "/seg/0.bin")}
bad = {"nourl": True}
with pytest.raises(RuntimeError):
with pytest.raises(RuntimeError) as raised:
run_mp([good, bad], tmp_path)
assert not hasattr(raised.value, "error_code")
def test_a_full_disk_in_a_child_keeps_its_download_error_code(server, tmp_path, monkeypatch):
monkeypatch.setattr(dl, "mp_worker", full_disk_worker)
with pytest.raises(RuntimeError) as raised:
run_mp([{"url": url(server, "/seg/0.bin")}, {"url": url(server, "/seg/1.bin")}], tmp_path)
assert dl.retries_exhausted(raised.value)
assert categorize_exception(raised.value).error_code == APIErrorCode.DOWNLOAD_ERROR
def test_multiprocess_child_death_raises(tmp_path, monkeypatch):
monkeypatch.setattr(dl, "mp_worker", die_without_result)