Add async lock protection to geo service cache and mark Task 16 done

This commit is contained in:
2026-04-17 16:51:05 +02:00
parent 04b2e2f700
commit 1e2850a34e
6 changed files with 77 additions and 56 deletions

View File

@@ -700,7 +700,7 @@ class TestOriginFilter:
assert len(result.bans) == 205
assert all(b.country_code == "DE" for b in result.bans)
geo_service.clear_cache()
await geo_service.clear_cache()
async def test_bans_by_country_source_archive_reads_archive(
self, app_db_with_archive: aiosqlite.Connection
@@ -769,7 +769,7 @@ class TestBansbyCountryBackground:
assert result.total == 3
# Country counts should reflect the cached data.
assert "DE" in result.countries or "US" in result.countries or "JP" in result.countries
geo_service.clear_cache()
await geo_service.clear_cache()
async def test_uncached_ips_trigger_background_task(
self, mixed_origin_db_path: str
@@ -778,7 +778,7 @@ class TestBansbyCountryBackground:
resolution and the response returns without blocking."""
from app.services import geo_service
geo_service.clear_cache() # ensure cache is empty
await geo_service.clear_cache() # ensure cache is empty
with (
patch(
@@ -810,7 +810,7 @@ class TestBansbyCountryBackground:
"""When http_session is None, no background task is created."""
from app.services import geo_service
geo_service.clear_cache()
await geo_service.clear_cache()
with (
patch(