OSM: asyncio.create_task statt BackgroundTasks — Hintergrund-Fetch funktioniert jetzt
BackgroundTasks wurde nicht ausgeführt (Bug in der Starlette-Integration). asyncio.create_task() plant den Overpass-Fetch direkt im Event-Loop ein, Argumente explizit übergeben statt Closure um Capture-Probleme zu vermeiden.
This commit is contained in:
parent
8cc528350d
commit
ddff1d3571
1 changed files with 5 additions and 6 deletions
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue