wiglenet: Add timeouts to _tileupdate calls

This commit is contained in:
Teemu Ikonen
2023-06-13 15:55:44 +03:00
parent f3709030cd
commit 29ab612439

View File

@@ -410,10 +410,14 @@ class WiglenetResolver(ResolverBase):
networks_updated = False
neighbours = (x for x in itertools.product(
range(-1, 2), range(-1, 2)) if x != (0, 0))
for x, y in neighbours:
tile = mercantile.Tile(center.x + x, center.y + y, center.z)
async with self.search_lock:
networks_updated |= await self._tileupdate(nettype, tile)
try:
for x, y in neighbours:
tile = mercantile.Tile(center.x + x, center.y + y, center.z)
async with asyncio.timeout(30):
async with self.search_lock:
networks_updated |= await self._tileupdate(nettype, tile)
except TimeoutError:
log.debug("Timeout on _update_neighbour_tiles")
return networks_updated
@@ -549,8 +553,13 @@ class WiglenetResolver(ResolverBase):
if searchcoords is not None and self.can_search():
tile = webmercator_tile(searchcoords[0], searchcoords[1], self.tile_min_z)
try:
async with self.search_lock:
updated = await self._tileupdate(nettype, tile)
# timeout needs to be lower than 20 s locate query timeout in server.py
async with asyncio.timeout(15):
async with self.search_lock:
updated = await self._tileupdate(nettype, tile)
except TimeoutError:
log.debug("Timeout on _tileupdate")
updated = False
except aiohttp.ClientError as e:
log.error('Client error on search query: ' + str(e))
updated = False