handle check task being cancelled while view is shown
This commit is contained in:
parent
de18cc977f
commit
394cfc723c
|
@ -65,9 +65,7 @@ class RefreshController(BaseController):
|
|||
@property
|
||||
def check_state(self):
|
||||
task = self.check_task.task
|
||||
if not task.done():
|
||||
return CheckState.UNKNOWN
|
||||
if task.cancelled():
|
||||
if not task.done() or task.cancelled():
|
||||
return CheckState.UNKNOWN
|
||||
if task.exception():
|
||||
return CheckState.UNAVAILABLE
|
||||
|
|
|
@ -163,10 +163,18 @@ class RefreshView(BaseView):
|
|||
schedule_task(self._wait_check_result())
|
||||
|
||||
async def _wait_check_result(self):
|
||||
while True:
|
||||
try:
|
||||
check_state = await self.controller.check_task.task
|
||||
except asyncio.CancelledError:
|
||||
# If the task was cancelled, another will have been
|
||||
# started.
|
||||
continue
|
||||
except Exception as e:
|
||||
self.check_state_failed(e)
|
||||
return
|
||||
else:
|
||||
break
|
||||
if check_state == CheckState.AVAILABLE:
|
||||
self.check_state_available()
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue