wiglenet: Hold a ref to the _update_neighbour_tiles bg task while it's running

This commit is contained in:
Teemu Ikonen
2023-06-13 15:06:18 +03:00
parent 057dd67557
commit f3709030cd

View File

@@ -172,6 +172,7 @@ class WiglenetResolver(ResolverBase):
self.detail_validate = fastjsonschema.compile(wiglenet_v3_detail_valid_schema) self.detail_validate = fastjsonschema.compile(wiglenet_v3_detail_valid_schema)
self.search_lock = asyncio.Lock() self.search_lock = asyncio.Lock()
self.detail_lock = asyncio.Lock() self.detail_lock = asyncio.Lock()
self._background_tasks = set()
def can_search(self): def can_search(self):
if (self.searchq_disabled_at is not None if (self.searchq_disabled_at is not None
@@ -557,7 +558,9 @@ class WiglenetResolver(ResolverBase):
cacheres = self._cachecall(netid) cacheres = self._cachecall(netid)
if not isinstance(cacheres, bool): if not isinstance(cacheres, bool):
return cacheres return cacheres
asyncio.create_task(self._update_neighbour_tiles(nettype, tile)) task = asyncio.create_task(self._update_neighbour_tiles(nettype, tile))
self._background_tasks.add(task)
task.add_done_callback(self._background_tasks.discard)
return netd return netd