switch to SingleInstanceTask in mirror controller

This commit is contained in:
Michael Hudson-Doyle 2019-12-20 11:17:34 +13:00
parent 2b0ee84ccb
commit e33e65dd20
1 changed files with 3 additions and 2 deletions

View File

@ -20,7 +20,7 @@ from xml.etree import ElementTree
from subiquitycore.async_helpers import ( from subiquitycore.async_helpers import (
run_in_thread, run_in_thread,
schedule_task, SingleInstanceTask,
) )
from subiquitycore.controller import BaseController from subiquitycore.controller import BaseController
@ -49,11 +49,12 @@ class MirrorController(BaseController):
if 'country-code' in self.answers: if 'country-code' in self.answers:
self.check_state = CheckState.DONE self.check_state = CheckState.DONE
self.model.set_country(self.answers['country-code']) self.model.set_country(self.answers['country-code'])
self.lookup_task = SingleInstanceTask(self.lookup)
def snapd_network_changed(self): def snapd_network_changed(self):
if self.check_state != CheckState.DONE: if self.check_state != CheckState.DONE:
self.check_state = CheckState.CHECKING self.check_state = CheckState.CHECKING
schedule_task(self.lookup()) self.lookup_task.start_sync()
async def lookup(self): async def lookup(self):
with self.context.child("lookup"): with self.context.child("lookup"):