Télécharger la pyramide du worker sans pause, garder la pause pour le rendu local du Pi

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Antoine Jacquin
2026-09-27 13:50:49 +02:00
parent 6e1b26986c
commit c5097e21a0
3 changed files with 32 additions and 6 deletions

View File

@ -1086,7 +1086,7 @@ def test_background_downloads_tiles_from_upstream(tmp_path, monkeypatch):
z = 13
x, y = _tile_of_cell(1054, 6882, z)
mapserve._bg_enqueue([("aspect", z, x, y)])
assert mapserve._bg_process_one() is True
assert mapserve._bg_process_one() == "telechargee"
assert calls == [f"tiles/aspect/{z}/{x}/{y}@2x.avif"]
cache = tiles.tile_cache_path(tmp_path, "aspect", z, x, y, 2, "avif")
assert cache.read_bytes() == AVIF
@ -1096,6 +1096,28 @@ def test_background_downloads_tiles_from_upstream(tmp_path, monkeypatch):
assert state == "fresh" and data == AVIF
def test_background_downloads_without_pause(monkeypatch):
"""Tuiles téléchargées de l'amont enchaînées sans pause ; rendu local
et rapatriement de source gardent la pause."""
import lidar_pipeline.mapserve as mapserve
results = iter(["telechargee", "telechargee", True])
waits = []
class Stop:
def is_set(self):
return len(waits) >= 1
def wait(self, delay):
waits.append(delay)
monkeypatch.setattr(mapserve, "_bg", {**mapserve._bg, "stop": Stop()})
monkeypatch.setattr(mapserve, "_bg_process_one", lambda: next(results))
monkeypatch.setenv("LIDAR_TILE_BACKGROUND_PAUSE", "0.2")
monkeypatch.setattr(mapserve.os, "nice", lambda n: 0)
mapserve._bg_worker()
assert waits == [0.2]
def test_background_renders_locally_when_upstream_down(tmp_path, monkeypatch):
"""Amont éteint : la maintenance rend la tuile localement (autonomie)."""
import lidar_pipeline.mapserve as mapserve
@ -1186,7 +1208,7 @@ def test_background_tiles_before_sources(tmp_path, monkeypatch):
z = 13
x, y = _tile_of_cell(1054, 6882, z)
mapserve._bg_enqueue([("aspect", z, x, y)])
assert mapserve._bg_process_one() is True
assert mapserve._bg_process_one() == "telechargee"
assert fetched == [] and mapserve._bg["stats"]["telechargees"] == 1
assert mapserve._bg_process_one() is True
assert fetched == [1]