diff --git a/backend/routes/osm.py b/backend/routes/osm.py index ddec009..d2927ce 100644 --- a/backend/routes/osm.py +++ b/backend/routes/osm.py @@ -167,7 +167,6 @@ async def get_pois( north: float = Query(...), east: float = Query(...), fast: bool = Query(False), - background_tasks: BackgroundTasks = None, user = Depends(get_optional_user), ): result = [] @@ -178,11 +177,11 @@ async def get_pois( stale = _stale_tiles(type, tiles) if stale and not fast: - # Hintergrund-Fetch: Antwort kommt sofort, Overpass lädt asynchron - async def _bg_fetch(): - for (x, y) in stale: - await _fetch_and_store_tile(type, x, y) - background_tasks.add_task(_bg_fetch) + # Direkt in den Event-Loop einplanen — Antwort kommt sofort zurück + async def _bg_fetch(poi_type, stale_tiles): + for (x, y) in stale_tiles: + await _fetch_and_store_tile(poi_type, x, y) + asyncio.create_task(_bg_fetch(type, stale)) with db() as conn: reported = {